Skip to content

ParseObject.update/ParseInstallation.create/ParseSession.installationId #264

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 2 commits into from
Sep 3, 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
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.DS_Store
.dart_tool/

.history
.packages
.pub/
pubspec.lock
Expand Down
13 changes: 9 additions & 4 deletions lib/src/objects/parse_installation.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class ParseInstallation extends ParseObject {
_client = client ??
ParseHTTPClient(
sendSessionId:
autoSendSessionId ?? ParseCoreData().autoSendSessionId,
autoSendSessionId ?? ParseCoreData().autoSendSessionId,
securityContext: ParseCoreData().securityContext);
}

Expand Down Expand Up @@ -130,11 +130,11 @@ class ParseInstallation extends ParseObject {
final CoreStore coreStore = await ParseCoreData().getStore();

final String installationJson =
await coreStore.getString(keyParseStoreInstallation);
await coreStore.getString(keyParseStoreInstallation);

if (installationJson != null) {
final Map<String, dynamic> installationMap =
json.decode(installationJson);
json.decode(installationJson);

if (installationMap != null) {
return ParseInstallation()..fromJson(installationMap);
Expand All @@ -161,11 +161,16 @@ class ParseInstallation extends ParseObject {
try {
final String uri = '${_client.data.serverUrl}$keyEndPointInstallations';
final String body = json.encode(toJson(forApiRQ: true));
final Map<String, String> headers = {
keyHeaderContentType: keyHeaderContentTypeJson
};
if (_debug) {
logRequest(ParseCoreData().appName, parseClassName,
ParseApiRQ.create.toString(), uri, body);
}
final Response result = await _client.post(uri, body: body);

final Response result =
await _client.post(uri, body: body, headers: headers);

//Set the objectId on the object after it is created.
//This allows you to perform operations on the object after creation
Expand Down
10 changes: 5 additions & 5 deletions lib/src/objects/parse_object.dart
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,9 @@ class ParseObject extends ParseBase implements ParseCloneable {
final Uri url = getSanitisedUri(_client, '$_path/$objectId');
final String body = json.encode(toJson(forApiRQ: true));
_saveChanges();
final Response result = await _client.put(url, body: body);
final Map<String, String> headers = {keyHeaderContentType:keyHeaderContentTypeJson};
final Response result =
await _client.put(url, body: body, headers: headers);
return handleResponse<ParseObject>(
this, result, ParseApiRQ.save, _debug, parseClassName);
} on Exception catch (e) {
Expand All @@ -104,8 +106,7 @@ class ParseObject extends ParseBase implements ParseCloneable {
if (response != null) {
if (response.success) {
_savingChanges.clear();
}
else {
} else {
_revertSavingChanges();
}
return response;
Expand Down Expand Up @@ -175,8 +176,7 @@ class ParseObject extends ParseBase implements ParseCloneable {
if (response.results[i] is ParseError) {
// Batch request succeed, but part of batch failed.
chunk[i]._revertSavingChanges();
}
else {
} else {
chunk[i]._savingChanges.clear();
}
}
Expand Down
11 changes: 6 additions & 5 deletions lib/src/objects/parse_session.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,15 @@ class ParseSession extends ParseObject implements ParseCloneable {

String get installationId => super.get<String>(keyVarInstallationId);

set installationId(String installationId) =>
set<String>(keyVarInstallationId, installationId);


Future<ParseResponse> getCurrentSessionFromServer() async {
try {
final Uri tempUri = Uri.parse(_client.data.serverUrl);

final Uri url = Uri(
scheme: tempUri.scheme,
host: tempUri.host,
path: '${tempUri.path}$keyEndPointSessions/me');
const String path = '$keyEndPointSessions/me';
final Uri url = getSanitisedUri(_client, path);

final Response response = await _client.get(url);

Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ environment:
dependencies:
flutter:
sdk: flutter

# Networking
web_socket_channel: ^1.0.9
http: ^0.12.0
Expand Down