parse-stack 1.5.3 → 1.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (55) hide show
  1. checksums.yaml +4 -4
  2. data/.github/parse-ruby-sdk.png +0 -0
  3. data/Changes.md +25 -1
  4. data/Gemfile.lock +4 -4
  5. data/README.md +37 -31
  6. data/bin/console +3 -0
  7. data/lib/parse/api/all.rb +2 -1
  8. data/lib/parse/api/apps.rb +12 -0
  9. data/lib/parse/api/config.rb +5 -1
  10. data/lib/parse/api/files.rb +1 -0
  11. data/lib/parse/api/hooks.rb +1 -0
  12. data/lib/parse/api/objects.rb +4 -1
  13. data/lib/parse/api/push.rb +1 -0
  14. data/lib/parse/api/{schemas.rb → schema.rb} +7 -0
  15. data/lib/parse/api/server.rb +44 -0
  16. data/lib/parse/api/sessions.rb +1 -0
  17. data/lib/parse/api/users.rb +4 -1
  18. data/lib/parse/client.rb +109 -73
  19. data/lib/parse/client/authentication.rb +2 -1
  20. data/lib/parse/client/batch.rb +9 -1
  21. data/lib/parse/client/body_builder.rb +16 -1
  22. data/lib/parse/client/caching.rb +15 -13
  23. data/lib/parse/client/protocol.rb +27 -15
  24. data/lib/parse/client/response.rb +26 -8
  25. data/lib/parse/model/acl.rb +1 -1
  26. data/lib/parse/model/associations/belongs_to.rb +18 -19
  27. data/lib/parse/model/associations/collection_proxy.rb +6 -0
  28. data/lib/parse/model/associations/has_many.rb +5 -6
  29. data/lib/parse/model/bytes.rb +4 -1
  30. data/lib/parse/model/classes/user.rb +46 -44
  31. data/lib/parse/model/core/actions.rb +508 -460
  32. data/lib/parse/model/core/builder.rb +75 -0
  33. data/lib/parse/model/core/errors.rb +9 -0
  34. data/lib/parse/model/core/fetching.rb +42 -38
  35. data/lib/parse/model/core/properties.rb +46 -27
  36. data/lib/parse/model/core/querying.rb +231 -228
  37. data/lib/parse/model/core/schema.rb +76 -74
  38. data/lib/parse/model/date.rb +10 -2
  39. data/lib/parse/model/file.rb +16 -2
  40. data/lib/parse/model/geopoint.rb +9 -2
  41. data/lib/parse/model/model.rb +38 -7
  42. data/lib/parse/model/object.rb +60 -19
  43. data/lib/parse/model/pointer.rb +22 -1
  44. data/lib/parse/model/push.rb +6 -2
  45. data/lib/parse/query.rb +57 -11
  46. data/lib/parse/query/constraint.rb +5 -2
  47. data/lib/parse/query/constraints.rb +588 -589
  48. data/lib/parse/query/ordering.rb +2 -2
  49. data/lib/parse/stack.rb +1 -0
  50. data/lib/parse/stack/version.rb +1 -1
  51. data/lib/parse/webhooks.rb +30 -29
  52. data/lib/parse/webhooks/payload.rb +181 -168
  53. data/lib/parse/webhooks/registration.rb +1 -1
  54. data/parse-stack.gemspec +9 -9
  55. metadata +9 -12
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 54b0162fed5af5493439188b14b21db3eb1c7ff9
4
- data.tar.gz: 17f07ddd2e7a79157f54769c46cee32b4aa03b97
3
+ metadata.gz: 521333b9d84cd7319911a0e9b368fbfa6133e98e
4
+ data.tar.gz: 543f3204ab4f4a9df14cbe88aa71be7bd0c69c47
5
5
  SHA512:
6
- metadata.gz: 93ae12440065bd3aeb3563457048bda7b60b07b08d2169381676d1638ea7acf364f3c9c1d033a741883bc21537f3decd8508bc83968a8ce326fae8004c60c5bd
7
- data.tar.gz: cd29ad6665369388220d1599aa375323bbf872e6054541a34a660ebd71b206ddb87a3b8252391b6564c7fe2a0d4481d776ee910efef2509e772c30170469e867
6
+ metadata.gz: 08b3de4ccf9cd5fdaa9045676b1147600bd3698d0cb99bc526d5172defbedc93e039d994f28350c291ad384470b96830d0e5186dbc5b6710255a95445af57a3b
7
+ data.tar.gz: 206b597203c7df406463f4a778934c7d79cf3ac76a950803c843bd5fd8b9c5020bdda7b6cd69938c1c738034973114759307b25c6ce1f451e998ac3c15b0797a
Binary file
data/Changes.md CHANGED
@@ -1,5 +1,28 @@
1
1
  ## Parse-Stack Changelog
2
2
 
3
+ ### 1.6.0
4
+ - NEW: Auto generate models based on your remote schema.
5
+ - The default server url is now 'http://localhost:1337/parse'.
6
+ - Improves thread-safety of Webhooks middleware.
7
+ - Performance improvements.
8
+ - BeforeSave change payloads do not include the className field.
9
+ - Reaches 100% documentation (will try to keep it up).
10
+ - Retry mechanism now configurable per client through `retry_limit`.
11
+ - Retry now follows sampling back-off delay algorithm.
12
+ - Adds `schemas` API to retrieve all schemas for an application.
13
+ - :number can now be used as an alias for the :integer data type.
14
+ - :geo_point can now be used as an alias for the :geopoint data type.
15
+ - Support accessing properties of Parse::Object subclasses through the [] operator.
16
+ - Support setting properties of Parse::Object subclasses through the []= operator.
17
+ - :to_s method of Parse::Date returns the iso8601(3) by default, if no arguments are provided.
18
+ - Parse::ConstraintError has been removed in favor of ArgumentError.
19
+ - Parse::Payload has been placed under Parse::Webhooks::Payload for clarity.
20
+ - Parse::WebhookErrorResponse has been moved to Parse::Webhooks::ResponseError.
21
+ - Moves Parse::Object modular functionality under Core namespace
22
+ - Renames ClassBuilder to Parse::Model::Builder
23
+ - Renamed SaveFailureError to RecordNotSaved for ActiveRecord similarity.
24
+ - All Parse errors inherit from Parse::Error.
25
+
3
26
  ### 1.5.3
4
27
  - Several fixes and performance improvements.
5
28
  - Major revisions to documentation.
@@ -18,6 +41,7 @@
18
41
  - Parse::File now has a `force_ssl` option that makes sure all urls returned are `https`.
19
42
  - Documentation
20
43
  - ParseConstraintError is now Parse::ConstraintError.
44
+ - All constraint subclasses are under the Constraint namespace.
21
45
 
22
46
  ### 1.5.1
23
47
  - BREAKING CHANGE: The default `has_many` implementation is `:query` instead of `:array`.
@@ -101,7 +125,7 @@
101
125
  ### 1.3.0
102
126
  - **IMPORTANT**: __Raising an error no longer sends an error response back to
103
127
  the client in a Webhook trigger. You must now call `error!('...')` instead of
104
- calling `raise '...'`.__ The webhook block is now binded to the Parse::Payload
128
+ calling `raise '...'`.__ The webhook block is now binded to the Parse::Webhooks::Payload
105
129
  instance, removing the need to pass `payload` object; use the instance methods directly.
106
130
  See updated README.md for more details.
107
131
  - **Parse-Stack will throw new exceptions** depending on the error code returned by Parse. These
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- parse-stack (1.5.3)
4
+ parse-stack (1.6.0)
5
5
  active_model_serializers (>= 0.9, < 1)
6
6
  activemodel (>= 4.2.1, < 6)
7
7
  activesupport (>= 4.2.1, < 6)
@@ -48,10 +48,10 @@ GEM
48
48
  debug_inspector (0.0.2)
49
49
  dotenv (2.1.1)
50
50
  erubis (2.7.0)
51
- faraday (0.9.2)
51
+ faraday (0.10.0)
52
52
  multipart-post (>= 1.2, < 3)
53
- faraday_middleware (0.10.0)
54
- faraday (>= 0.7.4, < 0.10)
53
+ faraday_middleware (0.10.1)
54
+ faraday (>= 0.7.4, < 1.0)
55
55
  i18n (0.7.0)
56
56
  jsonapi (0.1.1.beta6)
57
57
  jsonapi-parser (= 0.1.1.beta3)
data/README.md CHANGED
@@ -1,5 +1,8 @@
1
- # Parse-Stack - The Parse Server Ruby SDK
2
- Parse-Stack is a [Parse Server](https://github.com/ParsePlatform/parse-server) SDK and ORM framework for Ruby. It provides a client adapter, a query engine, an object relational mapper (ORM) and a Cloud Code Webhooks rack application.
1
+ <img src='https://raw.githubusercontent.com/modernistik/parse-stack/master/.github/parse-ruby-sdk.png?raw=true' width='500' alt='Ruby Parse SDK'/>
2
+
3
+ Parse-Stack is the [Parse Server](https://github.com/ParsePlatform/parse-server) SDK and ORM framework for [Ruby](https://www.ruby-lang.org/en/). It provides a client adapter, a query engine, an object relational mapper (ORM) and a Cloud Code Webhooks rack application.
4
+
5
+ Below is a [quick start guide](https://github.com/modernistik/parse-stack#overview), but you can also check out the full [API Reference](http://www.rubydoc.info/github/modernistik/parse-stack) for more detailed information about our Parse Server SDK.
3
6
 
4
7
  ### Code Status
5
8
  [![Gem Version](https://badge.fury.io/rb/parse-stack.svg)](https://badge.fury.io/rb/parse-stack)
@@ -31,7 +34,7 @@ Parse-Stack comes with support for Rails by adding additional rake tasks and gen
31
34
 
32
35
  For a more details on the rails integration see [Parse-Stack Rails Example](https://github.com/modernistik/parse-stack-rails-example).
33
36
 
34
- ## Table Of Contents
37
+ # Parse-Stack - The Parse Server Ruby SDK
35
38
  <!-- START doctoc generated TOC please keep comment here to allow auto update -->
36
39
  <!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
37
40
 
@@ -45,6 +48,7 @@ For a more details on the rails integration see [Parse-Stack Rails Example](http
45
48
  - [Field Naming Conventions](#field-naming-conventions)
46
49
  - [Connection Setup](#connection-setup)
47
50
  - [Connection Options](#connection-options)
51
+ - [Working With Existing Schemas](#working-with-existing-schemas)
48
52
  - [Parse Config](#parse-config)
49
53
  - [Core Classes](#core-classes)
50
54
  - [Parse::Pointer](#parsepointer)
@@ -147,7 +151,6 @@ For a more details on the rails integration see [Parse-Stack Rails Example](http
147
151
  - [Register Webhooks](#register-webhooks)
148
152
  - [Parse REST API Client](#parse-rest-api-client)
149
153
  - [Request Caching](#request-caching)
150
- - [Installation](#installation)
151
154
  - [Development](#development)
152
155
 
153
156
  <!-- END doctoc generated TOC please keep comment here to allow auto update -->
@@ -159,15 +162,15 @@ Parse-Stack is a full stack framework that utilizes several ideas behind [DataMa
159
162
 
160
163
  require 'parse/stack'
161
164
 
162
- Parse.setup app_id: APP_ID,
165
+ Parse.setup server_url: 'https://localhost:1337/parse',
166
+ app_id: APP_ID,
163
167
  api_key: REST_API_KEY,
164
- master_key: YOUR_MASTER_KEY,
165
- server_url: 'https://api.parse.com/1/'
168
+ master_key: YOUR_MASTER_KEY # optional
166
169
 
167
- # login
168
- user = Parse::User.login(username, passwd)
170
+ # Automatically build models based on your Parse application schemas.
171
+ Parse.auto_generate_models!
169
172
 
170
- # Custom Subclasses
173
+ # or define custom Subclasses (Highly Recommended)
171
174
  class Song < Parse::Object
172
175
  property :name
173
176
  property :play, :integer
@@ -191,6 +194,9 @@ end
191
194
  # updates schemas for your Parse app based on your models (non-destructive)
192
195
  Parse.auto_upgrade!
193
196
 
197
+ # login
198
+ user = Parse::User.login(username, passwd)
199
+
194
200
  artist = Artist.new(name: "Frank Sinatra", genres: ["swing", "jazz"])
195
201
  artist.fans << user
196
202
  artist.save
@@ -316,6 +322,19 @@ Sets the default cache expiration time (in seconds) for successful non-empty `GE
316
322
  #### `:faraday`
317
323
  You may pass a hash of options that will be passed to the `Faraday` constructor.
318
324
 
325
+ ## Working With Existing Schemas
326
+ If you already have a Parse application with defined schemas and collections, you can have Parse-Stack automatically generate the ruby Parse::Object subclasses instead of writing them on your own. Through this process, the framework will download all the defined schemas of all your collections, and infer the properties and associations defined. While this method is useful for getting started with the framework with an existing app, we highly recommend definiting your own models. This would allow you to customize and utilize all the features availabling in Parse::Stack.
327
+
328
+ ```ruby
329
+ # after you have called Parse.setup
330
+ # Assume you have a Song and Artist collections defined remotely
331
+ Parse.auto_generate_models!
332
+
333
+ # You can now use them as if you defined them
334
+ artist = Artist.first
335
+ Song.all(artist: artist)
336
+ ```
337
+
319
338
  ## Parse Config
320
339
  Getting your configuration variables once you have a default client setup can be done with `Parse.config`. The first time this method is called, Parse-Stack will get the configuration from Parse Server, and cache it. To force a reload of the config, use `config!`. You
321
340
 
@@ -1295,7 +1314,7 @@ To commit a new record or changes to an existing record to Parse, use the `#save
1295
1314
  The save operation can handle both creating and updating existing objects. If you do not want to update the association data of a changed object, you may use the `#update` method to only save the changed property values. In the case where you want to force update an object even though it has not changed, to possibly trigger your `before_save` hooks, you can use the `#update!` method. In addition, just like with other ActiveModel objects, you may call `reload!` to fetch the current record again from the data store.
1296
1315
 
1297
1316
  #### Raising an exception when save fails
1298
- By default, we return `true` or `false` for save and destroy operations. If you prefer to have `Parse::Object` raise an exception instead, you can tell to do so either globally or on a per-model basis. When a save fails, it will raise a `Parse::SaveFailureError`.
1317
+ By default, we return `true` or `false` for save and destroy operations. If you prefer to have `Parse::Object` raise an exception instead, you can tell to do so either globally or on a per-model basis. When a save fails, it will raise a `Parse::RecordNotSaved`.
1299
1318
 
1300
1319
  ```ruby
1301
1320
  # globally across all models
@@ -1306,7 +1325,7 @@ By default, we return `true` or `false` for save and destroy operations. If you
1306
1325
  song.save!
1307
1326
  ```
1308
1327
 
1309
- When enabled, if an error is returned by Parse due to saving or destroying a record, due to your `before_save` or `before_delete` validation cloud code triggers, `Parse::Object` will return the a `Parse::SaveFailureError` exception type. This exception has an instance method of `#object` which contains the object that failed to save.
1328
+ When enabled, if an error is returned by Parse due to saving or destroying a record, due to your `before_save` or `before_delete` validation cloud code triggers, `Parse::Object` will return the a `Parse::RecordNotSaved` exception type. This exception has an instance method of `#object` which contains the object that failed to save.
1310
1329
 
1311
1330
  ### Modifying Associations
1312
1331
  Similar to `:array` types of properties, a `has_many` association is backed by a collection proxy class and requires the use of `#add` and `#remove` to modify the contents of the association in order for it to correctly manage changes and updates with Parse. Using `has_many` for associations has the additional functionality that we will only add items to the association if they are of a `Parse::Pointer` or `Parse::Object` type. By default, these associations are fetched with only pointer data. To fetch all the objects in the association, you can call `#fetch` or `#fetch!` on the collection. Note that because the framework supports chaining, it is better to only request the objects you need by utilizing their accessors.
@@ -1386,8 +1405,7 @@ songs.destroy
1386
1405
  ```
1387
1406
 
1388
1407
  ### Magic `save_all`
1389
- By default, all Parse queries have a maximum fetch limit of 1000. While using the `:max` option, Parse-Stack can increase this up to 11,000. In the cases where you need to update a large number of objects, you can utilize the `Parse::Object#save_all` method
1390
- to fetch, modify and save objects.
1408
+ By default, all Parse queries have a maximum fetch limit of 1000. While using the `:max` option, Parse-Stack can increase this up to 11,000. In the cases where you need to update a large number of objects, you can utilize the `Parse::Object#save_all` method to fetch, modify and save objects.
1391
1409
 
1392
1410
  This methodology works by continually fetching and saving older records related to the time you begin a `save_all` request (called an "anchor date"), until there are no records left to update. To enable this to work, you must have confidence that any modifications you make to the records will successfully save through you validations that may be present in your `before_save`. This is important, as saving a record will set its `updated_at` date to one newer than the "anchor date" of when the `save_all` started. This `save_all` process will stop whenever no more records match the provided constraints that are older than the "anchor date", or when an object that was previously updated, is seen again in a future fetch (_which means the object failed to save_). Note that `save_all` will automatically manage the correct `updated_at` constraints in the query, so it is recommended that you do not use it as part of the initial constraints.
1393
1411
 
@@ -1400,6 +1418,8 @@ This methodology works by continually fetching and saving older records related
1400
1418
  end
1401
1419
  ```
1402
1420
 
1421
+ If you plan on using this feature in a lot of places, we recommend making sure you have set a MongoDB index of at least `{ "_updated_at" : 1 }`.
1422
+
1403
1423
  ### Deleting
1404
1424
  You can destroy a Parse record, just call the `#destroy` method. It will return a boolean value whether it was successful.
1405
1425
 
@@ -2084,7 +2104,7 @@ Push notifications are implemented through the `Parse::Push` class. To send push
2084
2104
  ```
2085
2105
 
2086
2106
  ## Cloud Code Webhooks
2087
- Parse Parse allows you to receive Cloud Code webhooks on your own hosted server. The `Parse::Webhooks` class is a lightweight Rack application that routes incoming Cloud Code webhook requests and payloads to locally registered handlers. The payloads are `Parse::Payload` type of objects that represent that data that Parse sends webhook handlers. You can register any of the Cloud Code webhook trigger hooks (`beforeSave`, `afterSave`, `beforeDelete`, `afterDelete`) and function hooks.
2107
+ Parse Parse allows you to receive Cloud Code webhooks on your own hosted server. The `Parse::Webhooks` class is a lightweight Rack application that routes incoming Cloud Code webhook requests and payloads to locally registered handlers. The payloads are `Parse::Webhooks::Payload` type of objects that represent that data that Parse sends webhook handlers. You can register any of the Cloud Code webhook trigger hooks (`beforeSave`, `afterSave`, `beforeDelete`, `afterDelete`) and function hooks.
2088
2108
 
2089
2109
  ### Cloud Code Functions
2090
2110
  You can use the `route()` method to register handler blocks. The last value returned by the block will be returned back to the client in a success response. If `error!(value)` is called inside the block, we will return the correct Parse error response with the value you provided.
@@ -2092,7 +2112,7 @@ You can use the `route()` method to register handler blocks. The last value retu
2092
2112
  ```ruby
2093
2113
  # Register handling the 'helloWorld' function.
2094
2114
  Parse::Webhooks.route(:function, :helloWorld) do
2095
- # use the Parse::Payload instance methods in this block
2115
+ # use the Parse::Webhooks::Payload instance methods in this block
2096
2116
  name = params['name'].to_s #function params
2097
2117
  puts "CloudCode Webhook helloWorld called in Ruby!"
2098
2118
  # will return proper error response
@@ -2133,7 +2153,7 @@ end
2133
2153
  ```
2134
2154
 
2135
2155
  ### Cloud Code Triggers
2136
- You can register webhooks to handle the different object triggers: `:before_save`, `:after_save`, `:before_delete` and `:after_delete`. The `payload` object, which is an instance of `Parse::Payload`, contains several properties that represent the payload. One of the most important ones is `parse_object`, which will provide you with the instance of your specific Parse object. In `:before_save` triggers, this object already contains dirty tracking information of what has been changed.
2156
+ You can register webhooks to handle the different object triggers: `:before_save`, `:after_save`, `:before_delete` and `:after_delete`. The `payload` object, which is an instance of `Parse::Webhooks::Payload`, contains several properties that represent the payload. One of the most important ones is `parse_object`, which will provide you with the instance of your specific Parse object. In `:before_save` triggers, this object already contains dirty tracking information of what has been changed.
2137
2157
 
2138
2158
  ```ruby
2139
2159
  # recommended way
@@ -2309,20 +2329,6 @@ Song.client.clear_cache!
2309
2329
 
2310
2330
  ```
2311
2331
 
2312
- ## Installation
2313
-
2314
- Add this line to your application's Gemfile:
2315
-
2316
- ```ruby
2317
- gem 'parse-stack'
2318
- ```
2319
-
2320
- or install it locally
2321
-
2322
- ```ruby
2323
- $ gem install parse-stack
2324
- ```
2325
-
2326
2332
  ## Development
2327
2333
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake false` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
2328
2334
 
data/bin/console CHANGED
@@ -11,6 +11,9 @@ Parse.setup
11
11
  puts "[ParseServerURL] #{Parse.client.server_url}"
12
12
  puts "[ParseAppID] #{Parse.client.app_id}"
13
13
 
14
+ Parse.auto_generate_models!.each do |model|
15
+ puts "Generated #{model}"
16
+ end
14
17
  # You can add fixtures and/or initialization code here to make experimenting
15
18
  # with your gem easier. You can also use a different console, if you like.
16
19
 
data/lib/parse/api/all.rb CHANGED
@@ -11,7 +11,8 @@ require_relative "cloud_functions"
11
11
  require_relative "hooks"
12
12
  require_relative "objects"
13
13
  require_relative "push"
14
- require_relative "schemas"
14
+ require_relative "schema"
15
+ require_relative "server"
15
16
  require_relative "sessions"
16
17
  require_relative "users"
17
18
 
@@ -4,11 +4,14 @@
4
4
  module Parse
5
5
 
6
6
  module API
7
+ # @deprecated These specific APIs will no longer be available after Jan 28th, 2017.
7
8
  # Defines the Apps interface for the Parse REST API
8
9
  module Apps
9
10
 
11
+ # @!visibility private
10
12
  APPS_PATH = "apps"
11
13
 
14
+ # @deprecated This method will no longer be available after Jan 28th, 2017.
12
15
  # Fetch the application keys.
13
16
  # @param appid [String] the application id.
14
17
  # @param email [String] your hosted Parse account email.
@@ -16,11 +19,14 @@ module Parse
16
19
  # @param headers [Hash] additional HTTP headers to send with the request.
17
20
  # @note Only supported by the hosted Parse platform and not the open source Parse-Server.
18
21
  # @return [Parse::Response]
22
+ # @deprecated
19
23
  def fetch_app_keys(appid, email, password, headers: {})
24
+ warn "[Parse::Client#fetch_app_keys] This method will no longer be available after Jan 28th, 2017."
20
25
  headers.merge!( { Parse::Protocol::EMAIL => email, Parse::Protocol::PASSWORD => password } )
21
26
  request :get, "#{APPS_PATH}/#{appid}", headers: headers
22
27
  end
23
28
 
29
+ # @deprecated This method will no longer be available after Jan 28th, 2017.
24
30
  # Fetch the applications.
25
31
  # @param email [String] your hosted Parse account email.
26
32
  # @param password [String] your hosted Parse account password.
@@ -28,10 +34,12 @@ module Parse
28
34
  # @note Only supported by the hosted Parse platform and not the open source Parse-Server.
29
35
  # @return [Parse::Response]
30
36
  def fetch_apps(email, password, headers: {})
37
+ warn "[Parse::Client#fetch_apps] This method will no longer be available after Jan 28th, 2017."
31
38
  headers.merge!( { Parse::Protocol::EMAIL => email, Parse::Protocol::PASSWORD => password } )
32
39
  request :get, APPS_PATH, headers: headers
33
40
  end
34
41
 
42
+ # @deprecated This method will no longer be available after Jan 28th, 2017.
35
43
  # Create a new application in the hosted Parse Platform.
36
44
  # @param body [Hash] parameters for creating the app.
37
45
  # @param email [String] your hosted Parse account email.
@@ -40,10 +48,13 @@ module Parse
40
48
  # @note Only supported by the hosted Parse platform and not the open source Parse-Server.
41
49
  # @return [Parse::Response]
42
50
  def create_app(body, email, password, headers: {})
51
+ warn "[Parse::Client#create_app] This method will no longer be available after Jan 28th, 2017."
43
52
  headers.merge!( { Parse::Protocol::EMAIL => email, Parse::Protocol::PASSWORD => password } )
44
53
  request :post, APPS_PATH, body: body, headers: headers
45
54
  end
46
55
 
56
+ # @deprecated This method will no longer be available after Jan 28th, 2017.
57
+ # Updates information about a particular app.
47
58
  # @param appid [String] the application id.
48
59
  # @param body [Hash] parameters to update the app.
49
60
  # @param email [String] your hosted Parse account email.
@@ -52,6 +63,7 @@ module Parse
52
63
  # @note Only supported by the hosted Parse platform and not the open source Parse-Server.
53
64
  # @return [Parse::Response]
54
65
  def update_app(appid, body, email, password, headers: {})
66
+ warn "[Parse::Client#update_app] This method will no longer be available after Jan 28th, 2017."
55
67
  headers.merge!( { Parse::Protocol::EMAIL => email, Parse::Protocol::PASSWORD => password } )
56
68
  request :put, "#{APPS_PATH}/#{appid}", body: body, headers: headers
57
69
  end
@@ -6,8 +6,12 @@ module Parse
6
6
  module API
7
7
  # Defines the Config interface for the Parse REST API
8
8
  module Config
9
- # @return [Hash] the cached config hash for the client.
9
+
10
+ # @!attribute config
11
+ # @return [Hash] the cached config hash for the client.
10
12
  attr_accessor :config
13
+
14
+ # @!visibility private
11
15
  CONFIG_PATH = "config"
12
16
 
13
17
  # @return [Hash] force fetch the application configuration hash.
@@ -9,6 +9,7 @@ module Parse
9
9
  module API
10
10
  # Defines the Parse Files interface for the Parse REST API
11
11
  module Files
12
+ # @!visibility private
12
13
  FILES_PATH = "files"
13
14
 
14
15
  # Upload and create a Parse file.
@@ -7,6 +7,7 @@ module Parse
7
7
  module API
8
8
  # Defines the Parse webhooks interface for the Parse REST API
9
9
  module Hooks
10
+ # @!visibility private
10
11
  HOOKS_PREFIX = "hooks/"
11
12
  # The allowed set of Parse triggers.
12
13
  TRIGGER_NAMES = [:beforeSave, :afterSave, :beforeDelete, :afterDelete].freeze
@@ -10,8 +10,10 @@ module Parse
10
10
  # REST API methods for fetching CRUD operations on Parse objects.
11
11
  module Objects
12
12
  # The class prefix for fetching objects.
13
+ # @!visibility private
13
14
  CLASS_PATH_PREFIX = "classes/"
14
- # The class prefix mapping for fetching objects.
15
+
16
+ # @!visibility private
15
17
  PREFIX_MAP = { installation: "installations", _installation: "installations",
16
18
  user: "users", _user: "users",
17
19
  role: "roles", _role: "roles",
@@ -23,6 +25,7 @@ module Parse
23
25
  base.extend(ClassMethods)
24
26
  end
25
27
 
28
+ # Class methods to be applied to {Parse::Client}
26
29
  module ClassMethods
27
30
  # Get the API path for this class.
28
31
  # @param className [String] the name of the Parse collection.
@@ -6,6 +6,7 @@ module Parse
6
6
  module API
7
7
  # Defines the Parse Push notification service interface for the Parse REST API
8
8
  module Push
9
+ # @!visibility private
9
10
  PUSH_PATH = "push"
10
11
 
11
12
  # Update the schema for a collection.
@@ -6,8 +6,15 @@ module Parse
6
6
  module API
7
7
  # Defines the Schema interface for the Parse REST API
8
8
  module Schema
9
+ # @!visibility private
9
10
  SCHEMAS_PATH = "schemas"
10
11
 
12
+ # Get all the schemas for the application.
13
+ # @return [Parse::Response]
14
+ def schemas
15
+ request :get, SCHEMAS_PATH
16
+ end
17
+
11
18
  # Get the schema for a collection.
12
19
  # @param className [String] the name of the remote Parse collection.
13
20
  # @return [Parse::Response]
@@ -0,0 +1,44 @@
1
+ # encoding: UTF-8
2
+ # frozen_string_literal: true
3
+
4
+ module Parse
5
+
6
+ module API
7
+ # APIs related to the open source Parse Server.
8
+ module Server
9
+
10
+ # @!attribute server_info
11
+ # @return [Hash] the information about the server.
12
+ attr_accessor :server_info
13
+
14
+ # @!visibility private
15
+ SERVER_INFO_PATH = 'serverInfo'
16
+
17
+ # Fetch and cache information about the Parse server configuration. This
18
+ # hash contains information specifically to the configuration of the running
19
+ # parse server.
20
+ # @return (see #server_info!)
21
+ def server_info
22
+ return @server_info if @server_info.present?
23
+ response = request :get, SERVER_INFO_PATH
24
+ @server_info = response.error? ? nil :
25
+ response.result.with_indifferent_access
26
+ end
27
+
28
+ # Force fetches the server information.
29
+ # @return [Hash] a hash containing server configuration if available.
30
+ def server_info!
31
+ @server_info = nil
32
+ server_info
33
+ end
34
+
35
+ # Returns the version of the Parse server the client is connected to.
36
+ # @return [String] a version string (ex. '2.2.25') if available.
37
+ def server_version
38
+ server_info.present? ? @server_info[:parseServerVersion] : nil
39
+ end
40
+
41
+ end
42
+ end
43
+
44
+ end