Skip to content

Release/1.0.1 #19

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Jan 7, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
544 changes: 379 additions & 165 deletions .idea/workspace.xml

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
## 1.0.1

Added documentation and GeoPoints

## 1.0.0

First full release!

## 0.0.4

Added description
Expand Down
12 changes: 9 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
## Parse For Flutter!
Hi, this is a Flutter plugin that allows communication with a Parse Server, (https://parseplatform.org) either hosted on your own server or another, like (http://Back4App.com).

This is a work in project and we are consistently updating it. Please let us know if you think anything needs changing/adding, and more than ever, please do join in on this project.
This is a work in project and we are consistently updating it. Please let us know if you think anything needs changing/adding, and more than ever, please do join in on this project (Even if it is just to improve our documentation.

## Join in!
Want to get involved? Join our Slack channel and help out! (http://flutter-parse-sdk.slack.com)
Expand All @@ -13,7 +13,12 @@ Want to get involved? Join our Slack channel and help out! (http://flutter-parse
To install, either add to your pubspec.yaml
```
dependencies:
parse_server_sdk: ^1.0.0

parse_server_sdk: ^1.0.1




```
or clone this repository and add to your project. As this is an early development with multiple contributors, it is probably best to download/clone and keep updating as an when a new feature is added.

Expand All @@ -33,7 +38,7 @@ Parse().initialize(
ApplicationConstants.PARSE_APPLICATION_ID,
ApplicationConstants.PARSE_SERVER_URL,
masterKey: ApplicationConstants.PARSE_MASTER_KEY,
debug: true,
debug: true,
liveQuery: true);
```

Expand Down Expand Up @@ -170,6 +175,7 @@ Main:
* Objects
* Queries
* LiveQueries
* GeoPoints
* Debug Mode - Logging API calls
* Manage Session ID's tokens

Expand Down
2 changes: 1 addition & 1 deletion example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class _MyAppState extends State<MyApp> {
}

void getSingleItem() async {
var response = await DietPlan().get('R5EonpUDWy');
var response = await DietPlan().getObject('R5EonpUDWy');

if (response.success) {
print(ApplicationConstants.APP_NAME + ": " + (response.result as DietPlan).toString());
Expand Down
28 changes: 20 additions & 8 deletions lib/parse.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ import 'package:meta/meta.dart';
import 'package:web_socket_channel/io.dart';

part 'src/base/parse_constants.dart';
part 'src/data/parse_data.dart';
part 'src/data/parse_data_objects.dart';
part 'src/data/parse_data_server.dart';
part 'src/data/parse_data_user.dart';
part 'src/enums/parse_enum_function_call.dart';
Expand All @@ -23,30 +21,44 @@ part 'src/network/parse_query.dart';
part 'src/objects/parse_base.dart';
part 'src/objects/parse_exception.dart';
part 'src/objects/parse_function.dart';
part 'src/objects/parse_geo_point.dart';
part 'src/objects/parse_object.dart';
part 'src/objects/parse_response.dart';
part 'src/objects/parse_user.dart';

part 'src/utils/parse_utils_date.dart';
part 'src/utils/parse_utils_objects.dart';
part 'src/utils/parse_utils.dart';

class Parse {
ParseDataServer data;
final ParseHTTPClient client = new ParseHTTPClient();

Parse initialize(appId, serverUrl, {debug, appName, liveQueryUrl, masterKey, sessionId}) {
ParseDataServer.init(appId,
serverUrl,
/// To initialise Parse Server in your application
///
/// This should be initialised in MyApp() creation
///
/// ```
/// Parse().initialize(
// "PARSE_APP_ID",
// "https://parse.myaddress.com/parse/,
// masterKey: "asd23rjh234r234r234r",
// debug: true,
// liveQuery: true);
// ```
Parse initialize(appId, serverUrl,
{debug, appName, liveQueryUrl, masterKey, sessionId}) {
ParseDataServer.init(appId, serverUrl,
debug: debug,
appName: appName,
liveQueryUrl: liveQueryUrl,
masterKey: masterKey,
sessionId: sessionId);

return newInstance(ParseDataServer());
return _newInstance(ParseDataServer());
}

Parse newInstance(ParseDataServer data) {
/// Creates a singleton instance of [ParseDataServer] that contains all the server information
Parse _newInstance(ParseDataServer data) {
var parse = Parse();
parse.data = data;
parse.client.data = data;
Expand Down
1 change: 1 addition & 0 deletions lib/src/base/parse_constants.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
part of flutter_parse_sdk;

/// Class containing all constants for this library
class ParseConstants {

static const String PARSE_DATE_FORMAT = "yyyy-MM-dd'T'HH:mm";
Expand Down
29 changes: 0 additions & 29 deletions lib/src/data/parse_data.dart

This file was deleted.

19 changes: 0 additions & 19 deletions lib/src/data/parse_data_objects.dart

This file was deleted.

9 changes: 9 additions & 0 deletions lib/src/data/parse_data_server.dart
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
part of flutter_parse_sdk;

/// Singleton class that defines all user keys and data
class ParseDataServer {
static ParseDataServer _instance;
static ParseDataServer get instance => _instance;

/// Creates an instance of Parse Server
///
/// This class should not be user unless switching servers during the app,
/// which is odd. Should only be user by Parse.init
static void init(appId, serverUrl, {debug, appName, liveQueryUrl, masterKey, sessionId}){
_instance = ParseDataServer._init(appId, serverUrl);

Expand All @@ -28,6 +33,10 @@ class ParseDataServer {

factory ParseDataServer() => _instance;

/// Sets the current sessionId.
///
/// This is generated when a users logs in, or calls currentUser to update
/// their keys
void setSessionId(String sessionId){
this.sessionId = sessionId;
}
Expand Down
24 changes: 17 additions & 7 deletions lib/src/data/parse_data_user.dart
Original file line number Diff line number Diff line change
@@ -1,38 +1,48 @@
part of flutter_parse_sdk;

/// User class that contains the current user data
class User extends ParseBase {
static User _instance;

static User get instance => _instance;

/// Creates an instance of a ParseUser
static void init(username, password, emailAddress) =>
_instance ??= User._init(username, password, emailAddress);

/// Clears user data to mimic logout
static void logout() => _instance = null;

String acl;
String username;
String password;
String emailAddress;

/// Creates a singleton instance of a user.
///
/// There can only be one user
User._init(this.username, this.password, this.emailAddress): super();

factory User() => _instance;

/// Returns a [User] from a [Map] object
fromJson(Map objectData) {
if (getObjectData() == null) setObjectData(objectData);
getObjectData().addAll(objectData);
if (getObjectData().containsKey(ParseConstants.OBJECT_ID)) objectId = getValue(ParseConstants.OBJECT_ID).toString();
if (getObjectData().containsKey(ParseConstants.CREATED_AT)) createdAt = convertStringToDateTime(getValue(ParseConstants.CREATED_AT).toString());
if (getObjectData().containsKey(ParseConstants.UPDATED_AT)) updatedAt = convertStringToDateTime(getValue(ParseConstants.UPDATED_AT).toString());
if (getObjectData().containsKey(ACL)) acl = getValue(ACL).toString();
if (getObjectData().containsKey(USERNAME)) username = getValue(USERNAME).toString();
if (getObjectData().containsKey(PASSWORD)) password = getValue(PASSWORD).toString();
if (getObjectData().containsKey(EMAIL)) emailAddress = getValue(EMAIL).toString();
if (getObjectData().containsKey(ParseConstants.OBJECT_ID)) objectId = get(ParseConstants.OBJECT_ID).toString();
if (getObjectData().containsKey(ParseConstants.CREATED_AT)) createdAt = convertStringToDateTime(get(ParseConstants.CREATED_AT).toString());
if (getObjectData().containsKey(ParseConstants.UPDATED_AT)) updatedAt = convertStringToDateTime(get(ParseConstants.UPDATED_AT).toString());
if (getObjectData().containsKey(ACL)) acl = get(ACL).toString();
if (getObjectData().containsKey(USERNAME)) username = get(USERNAME).toString();
if (getObjectData().containsKey(PASSWORD)) password = get(PASSWORD).toString();
if (getObjectData().containsKey(EMAIL)) emailAddress = get(EMAIL).toString();

if (updatedAt == null) updatedAt = createdAt;

return this;
}

/// Returns a JSON string of the current user
Map<String, dynamic> toJson() => {
ACL: acl,
USERNAME: username,
Expand Down
14 changes: 2 additions & 12 deletions lib/src/enums/parse_enum_function_call.dart
Original file line number Diff line number Diff line change
@@ -1,14 +1,4 @@
part of flutter_parse_sdk;

enum ParseApiFunctionCallType { execute }

class ParseApiFunctionCallTypeUtil {
static getEnumValue(ParseApiFunctionCallType type) {
switch (type) {
case ParseApiFunctionCallType.execute:
{
return 'execure';
}
}
}
}
/// Used to define the API calls made in ParseFunction logs
enum ParseApiFunction { execute }
34 changes: 2 additions & 32 deletions lib/src/enums/parse_enum_object_call.dart
Original file line number Diff line number Diff line change
@@ -1,34 +1,4 @@
part of flutter_parse_sdk;

enum ParseApiObjectCallType { get, getAll, create, save, query, delete }

class ParseApiObjectCallTypeUtil {
static getEnumValue(ParseApiObjectCallType type) {
switch (type) {
case ParseApiObjectCallType.get:
{
return 'get';
}
case ParseApiObjectCallType.getAll:
{
return 'getAll';
}
case ParseApiObjectCallType.create:
{
return 'create';
}
case ParseApiObjectCallType.save:
{
return 'save';
}
case ParseApiObjectCallType.query:
{
return 'query';
}
case ParseApiObjectCallType.delete:
{
return 'delete';
}
}
}
}
/// Used to define the API calls made in ParseObject logs
enum ParseApiObject { get, getAll, create, save, query, delete }
42 changes: 2 additions & 40 deletions lib/src/enums/parse_enum_user_call.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
part of flutter_parse_sdk;

enum ParseApiUserCallType {
/// Used to define the API calls made in ParseUser logs
enum ParseApiUser {
currentUser,
signUp,
login,
Expand All @@ -10,42 +11,3 @@ enum ParseApiUserCallType {
destroy,
all
}

class ParseApiUserCallTypeUtils {
static getEnumValue(ParseApiUserCallType type) {
switch (type) {
case ParseApiUserCallType.currentUser:
{
return 'currentUser';
}
case ParseApiUserCallType.signUp:
{
return 'signUp';
}
case ParseApiUserCallType.login:
{
return 'login';
}
case ParseApiUserCallType.verificationEmailRequest:
{
return 'verificationEmailRequest';
}
case ParseApiUserCallType.requestPasswordReset:
{
return 'requestPasswordReset';
}
case ParseApiUserCallType.save:
{
return 'save';
}
case ParseApiUserCallType.destroy:
{
return 'destroy';
}
case ParseApiUserCallType.all:
{
return 'all';
}
}
}
}
2 changes: 2 additions & 0 deletions lib/src/network/parse_http_client.dart
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
part of flutter_parse_sdk;

/// Creates a custom version of HTTP Client that has Parse Data Preset
class ParseHTTPClient extends BaseClient {
final Client _client = new Client();
final String _userAgent = "Dart Parse SDK 0.1";
ParseDataServer data = ParseDataServer();

ParseHTTPClient();

/// Overrides the call method for HTTP Client and adds custom headers
@override
Future<StreamedResponse> send(BaseRequest request) {
request.headers['user-agent'] = _userAgent;
Expand Down
1 change: 1 addition & 0 deletions lib/src/network/parse_livequery.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
part of flutter_parse_sdk;

/// Still under development
class LiveQuery {
final ParseHTTPClient client;
var channel;
Expand Down
Loading