parse-stack 1.7.3 → 1.9.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (85) hide show
  1. checksums.yaml +5 -5
  2. data/.github/workflows/ruby.yml +36 -0
  3. data/.solargraph.yml +23 -0
  4. data/.travis.yml +6 -3
  5. data/Changes.md +84 -22
  6. data/Gemfile +14 -12
  7. data/Gemfile.lock +110 -60
  8. data/README.md +67 -24
  9. data/Rakefile +14 -14
  10. data/bin/parse-console +1 -0
  11. data/lib/parse/api/aggregate.rb +59 -0
  12. data/lib/parse/api/all.rb +2 -1
  13. data/lib/parse/api/analytics.rb +0 -3
  14. data/lib/parse/api/batch.rb +3 -5
  15. data/lib/parse/api/cloud_functions.rb +0 -3
  16. data/lib/parse/api/config.rb +0 -4
  17. data/lib/parse/api/files.rb +3 -7
  18. data/lib/parse/api/hooks.rb +4 -8
  19. data/lib/parse/api/objects.rb +9 -14
  20. data/lib/parse/api/push.rb +0 -4
  21. data/lib/parse/api/schema.rb +2 -6
  22. data/lib/parse/api/server.rb +4 -7
  23. data/lib/parse/api/sessions.rb +2 -5
  24. data/lib/parse/api/users.rb +9 -14
  25. data/lib/parse/client.rb +55 -50
  26. data/lib/parse/client/authentication.rb +29 -33
  27. data/lib/parse/client/batch.rb +8 -11
  28. data/lib/parse/client/body_builder.rb +19 -20
  29. data/lib/parse/client/caching.rb +23 -28
  30. data/lib/parse/client/protocol.rb +11 -12
  31. data/lib/parse/client/request.rb +4 -6
  32. data/lib/parse/client/response.rb +5 -7
  33. data/lib/parse/model/acl.rb +14 -12
  34. data/lib/parse/model/associations/belongs_to.rb +19 -24
  35. data/lib/parse/model/associations/collection_proxy.rb +328 -317
  36. data/lib/parse/model/associations/has_many.rb +22 -27
  37. data/lib/parse/model/associations/has_one.rb +7 -12
  38. data/lib/parse/model/associations/pointer_collection_proxy.rb +5 -13
  39. data/lib/parse/model/associations/relation_collection_proxy.rb +5 -9
  40. data/lib/parse/model/bytes.rb +8 -10
  41. data/lib/parse/model/classes/installation.rb +2 -4
  42. data/lib/parse/model/classes/product.rb +2 -5
  43. data/lib/parse/model/classes/role.rb +3 -5
  44. data/lib/parse/model/classes/session.rb +2 -5
  45. data/lib/parse/model/classes/user.rb +21 -17
  46. data/lib/parse/model/core/actions.rb +31 -46
  47. data/lib/parse/model/core/builder.rb +6 -6
  48. data/lib/parse/model/core/errors.rb +0 -1
  49. data/lib/parse/model/core/fetching.rb +45 -50
  50. data/lib/parse/model/core/properties.rb +53 -68
  51. data/lib/parse/model/core/querying.rb +292 -282
  52. data/lib/parse/model/core/schema.rb +89 -92
  53. data/lib/parse/model/date.rb +16 -23
  54. data/lib/parse/model/file.rb +171 -174
  55. data/lib/parse/model/geopoint.rb +12 -16
  56. data/lib/parse/model/model.rb +31 -37
  57. data/lib/parse/model/object.rb +58 -70
  58. data/lib/parse/model/pointer.rb +177 -176
  59. data/lib/parse/model/push.rb +8 -10
  60. data/lib/parse/model/shortnames.rb +1 -2
  61. data/lib/parse/model/time_zone.rb +3 -5
  62. data/lib/parse/query.rb +70 -37
  63. data/lib/parse/query/constraint.rb +4 -6
  64. data/lib/parse/query/constraints.rb +62 -20
  65. data/lib/parse/query/operation.rb +8 -11
  66. data/lib/parse/query/ordering.rb +45 -49
  67. data/lib/parse/stack.rb +15 -11
  68. data/lib/parse/stack/generators/rails.rb +28 -30
  69. data/lib/parse/stack/generators/templates/model.erb +5 -6
  70. data/lib/parse/stack/generators/templates/model_installation.rb +0 -1
  71. data/lib/parse/stack/generators/templates/model_role.rb +0 -1
  72. data/lib/parse/stack/generators/templates/model_session.rb +0 -1
  73. data/lib/parse/stack/generators/templates/model_user.rb +0 -1
  74. data/lib/parse/stack/generators/templates/parse.rb +9 -9
  75. data/lib/parse/stack/generators/templates/webhooks.rb +1 -2
  76. data/lib/parse/stack/railtie.rb +2 -4
  77. data/lib/parse/stack/tasks.rb +70 -86
  78. data/lib/parse/stack/version.rb +1 -1
  79. data/lib/parse/webhooks.rb +19 -26
  80. data/lib/parse/webhooks/payload.rb +26 -28
  81. data/lib/parse/webhooks/registration.rb +23 -31
  82. data/parse-stack.gemspec +28 -28
  83. data/parse-stack.png +0 -0
  84. metadata +27 -25
  85. data/.github/parse-ruby-sdk.png +0 -0
data/README.md CHANGED
@@ -1,15 +1,12 @@
1
- <img src='https://raw.githubusercontent.com/modernistik/parse-stack/master/.github/parse-ruby-sdk.png?raw=true' width='500' alt='Ruby Parse Server SDK'/>
1
+ ![Parse Stack - The Parse Server Ruby Client SDK](https://raw.githubusercontent.com/modernistik/parse-stack/master/parse-stack.png?raw=true)
2
2
 
3
- # Parse Stack - The Parse Server Ruby Client SDK
4
-
5
- [Parse Stack](https://github.com/modernistik/parse-stack) is the [Parse Server](http://parseplatform.org/) SDK, REST Client 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.
3
+ A full featured Active Model ORM and Ruby REST API for Parse-Server. [Parse Stack](https://github.com/modernistik/parse-stack) is the [Parse Server](http://parseplatform.org/) SDK, REST Client 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.
6
4
 
7
5
  Below is a [quick start guide](https://github.com/modernistik/parse-stack#overview), but you can also check out the full *[API Reference](https://www.modernistik.com/gems/parse-stack/index.html)* for more detailed information about our Parse Server SDK.
8
6
 
9
- #### Tutorial Videos
10
- 1. Getting Started: https://youtu.be/zoYSGmciDlQ
11
- 2. Custom Classes and Relations: https://youtu.be/tfSesotfU7w
12
- 3. Working with Existing Schemas: https://youtu.be/EJGPT7YWyXA
7
+ ### Hire Us
8
+
9
+ Interested in our work? You can find us here: [https://www.modernistik.com](https://www.modernistik.com)
13
10
 
14
11
  ### Code Status
15
12
  [![Gem Version](https://img.shields.io/gem/v/parse-stack.svg)](https://github.com/modernistik/parse-stack)
@@ -17,8 +14,12 @@ Below is a [quick start guide](https://github.com/modernistik/parse-stack#overvi
17
14
  [![Build Status](https://travis-ci.org/modernistik/parse-stack.svg?branch=master)](https://travis-ci.org/modernistik/parse-stack)
18
15
  [![API Reference](http://img.shields.io/badge/api-docs-blue.svg)](https://www.modernistik.com/gems/parse-stack/index.html)
19
16
 
20
- ### Questions?
21
- [![Gitter](https://badges.gitter.im/modernistik/parse-stack.svg)](https://gitter.im/modernistik/parse-stack?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)
17
+ #### Tutorial Videos
18
+ 1. Getting Started: https://youtu.be/zoYSGmciDlQ
19
+ 2. Custom Classes and Relations: https://youtu.be/tfSesotfU7w
20
+ 3. Working with Existing Schemas: https://youtu.be/EJGPT7YWyXA
21
+
22
+ Any other questions, please post them on StackOverflow with the proper parse-stack / parse-server / ruby tags.
22
23
 
23
24
  ## Installation
24
25
 
@@ -135,7 +136,7 @@ result = Parse.call_function :myFunctionName, {param: value}
135
136
  <!-- START doctoc generated TOC please keep comment here to allow auto update -->
136
137
  <!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
137
138
 
138
- - [Overview](#overview)
139
+
139
140
  - [Architecture](#architecture)
140
141
  - [Parse::Client](#parseclient)
141
142
  - [Parse::Query](#parsequery)
@@ -204,6 +205,7 @@ result = Parse.call_function :myFunctionName, {param: value}
204
205
  - [Advanced Querying](#advanced-querying)
205
206
  - [Results Caching](#results-caching)
206
207
  - [Counting](#counting)
208
+ - [Distinct Aggregation](#distinct-aggregation)
207
209
  - [Query Expressions](#query-expressions)
208
210
  - [:order](#order)
209
211
  - [:keys](#keys)
@@ -236,6 +238,7 @@ result = Parse.call_function :myFunctionName, {param: value}
236
238
  - [Max Distance Constraint](#max-distance-constraint)
237
239
  - [Bounding Box Constraint](#bounding-box-constraint)
238
240
  - [Polygon Area Constraint](#polygon-area-constraint)
241
+ - [Full Text Search Constraint](#full-text-search-constraint)
239
242
  - [Relational Queries](#relational-queries)
240
243
  - [Compound Queries](#compound-queries)
241
244
  - [Query Scopes](#query-scopes)
@@ -350,7 +353,7 @@ A caching adapter of type `Moneta::Transformer`. Caching queries and object fetc
350
353
  Parse.setup(cache: store, expires: 10, ...)
351
354
  ```
352
355
 
353
- As a shortcut, if you are planning on using REDIS and have configured the use of `redis` in your `Gemfile`, you can just pass the redis connection string directly to the cache option.
356
+ As a shortcut, if you are planning on using REDIS and have configured the use of `redis` in your `Gemfile`, you can just pass the REDIS connection string directly to the cache option.
354
357
 
355
358
  ```ruby
356
359
  Parse.setup(cache: 'redis://localhost:6379', ...)
@@ -363,7 +366,7 @@ Sets the default cache expiration time (in seconds) for successful non-empty `GE
363
366
  You may pass a hash of options that will be passed to the `Faraday` constructor.
364
367
 
365
368
  ## Working With Existing Schemas
366
- 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.
369
+ 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 defining your own models. This would allow you to customize and utilize all the features available in Parse Stack.
367
370
 
368
371
  ```ruby
369
372
  # after you have called Parse.setup
@@ -516,8 +519,6 @@ This class manages dates in the special JSON format it requires for properties o
516
519
  song.save # ok
517
520
  ```
518
521
 
519
- One important note with dates, is that `created_at` and `updated_at` columns do not follow this convention all the time. Depending on the Cloud Code SDK, they can be the Parse ISO hash date format or the `iso8601` string format. By default, these are serialized as `iso8601` when sent as responses to Parse for backwards compatibility with some clients. To use the Parse ISO hash format for these fields instead, set `Parse::Object.disable_serialized_string_date = true`.
520
-
521
522
  ### [Parse::GeoPoint](https://www.modernistik.com/gems/parse-stack/Parse/GeoPoint.html)
522
523
  This class manages the GeoPoint data type that Parse provides to support geo-queries. To define a GeoPoint property, use the `:geopoint` data type. Please note that latitudes should not be between -90.0 and 90.0, and longitudes should be between -180.0 and 180.0.
523
524
 
@@ -627,7 +628,7 @@ All `Parse::Object` subclasses have an `acl` property by default. With this prop
627
628
 
628
629
  artist.save
629
630
  ```
630
- You may also set default ACLs for newly created insatnces of your subclasses using `set_default_acl`:
631
+ You may also set default ACLs for newly created instances of your subclasses using `set_default_acl`:
631
632
 
632
633
  ```ruby
633
634
  class AdminData < Parse::Object
@@ -864,7 +865,7 @@ end
864
865
 
865
866
  After properties are defined, you can use appropriate getter and setter methods to modify the values. As properties become modified, the model will keep track of the changes using the [dirty tracking feature of ActiveModel](http://api.rubyonrails.org/classes/ActiveModel/Dirty.html). If an attribute is modified in-place then make use of **[attribute_name]_will_change!** to mark that the attribute is changing. Otherwise ActiveModel can't track changes to in-place attributes.
866
867
 
867
- To support dirty tracking on properties of data type of `:array`, we utilize a proxy class called `Parse::CollectionProxy`. This class has special functionality which allows lazy loading of content as well and keeping track of the changes that are made. While you are able to access the internal array on the collection through the `#collection` method, it is important not to make in-place edits to the object. You should use the preferred methods of `#add` and `#remove` to modify the contents of the collection. When `#save` is called on the object, the changes will be commited to Parse.
868
+ To support dirty tracking on properties of data type of `:array`, we utilize a proxy class called `Parse::CollectionProxy`. This class has special functionality which allows lazy loading of content as well and keeping track of the changes that are made. While you are able to access the internal array on the collection through the `#collection` method, it is important not to make in-place edits to the object. You should use the preferred methods of `#add` and `#remove` to modify the contents of the collection. When `#save` is called on the object, the changes will be committed to Parse.
868
869
 
869
870
  ```ruby
870
871
  post = Post.first
@@ -1525,7 +1526,7 @@ For the cases when you want to modify the items in this association without havi
1525
1526
  artist.songs.add! song # Add operation
1526
1527
  artist.songs.add_unique! other_song # AddUnique operation
1527
1528
  artist.songs.remove! another_song # Remove operation
1528
- artist.save # noop. operations were sent directly to Parse
1529
+ artist.save # no-op. (no operations were sent directly to Parse)
1529
1530
 
1530
1531
  artist.songs.destroy! # Delete operation of all Songs
1531
1532
  ```
@@ -1648,7 +1649,7 @@ However, Parse-Stack performs automatic fetching of associations when the associ
1648
1649
  song.artist.name
1649
1650
 
1650
1651
  # You can manually do the same with `fetch` and `fetch!`
1651
- song.artist.fetch # considered "fetch if needed". Noop if not needed.
1652
+ song.artist.fetch # considered "fetch if needed". No-op if not needed.
1652
1653
  song.artist.fetch! # force fetch regardless of state.
1653
1654
  ```
1654
1655
 
@@ -1733,7 +1734,8 @@ When a query API is made, the results are cached in the query object in case you
1733
1734
  ```
1734
1735
 
1735
1736
  ### Counting
1736
- If you only need to know the result count for a query, provide count a non-zero value. However, if you need to perform a count query, use `count()` method instead.
1737
+ If you only need to know the result count for a query, provide count a
1738
+ non-zero value. However, if you need to perform a count query, use `count()` method instead.
1737
1739
 
1738
1740
  ```ruby
1739
1741
  # get number of songs with a play_count > 10
@@ -1746,6 +1748,23 @@ If you only need to know the result count for a query, provide count a non-zero
1746
1748
 
1747
1749
  ```
1748
1750
 
1751
+ ### Distinct Aggregation
1752
+ Finds the distinct values for a specified field across a single collection or
1753
+ view and returns the results in an array. You may mix this with additional query constraints.
1754
+
1755
+ ```ruby
1756
+ # Return a list of unique city names
1757
+ # for users created in the last 10 days.
1758
+ User.distinct :city, :created_at.after => 10.days.ago
1759
+ # ex. ["San Diego", "Los Angeles", "San Juan"]
1760
+
1761
+ # same
1762
+ query = Parse::Query.new("_User")
1763
+ query.where :created_at.after => 10.days.ago
1764
+ query.distinct(:city) #=> ["San Diego", "Los Angeles", "San Juan"]
1765
+
1766
+ ```
1767
+
1749
1768
  ### Query Expressions
1750
1769
  The set of supported expressions based on what is available through the Parse REST API. _For those who don't prefer the DataMapper style syntax, we have provided method accessors for each of the expressions._ A full description of supported query operations, please refer to the [`Parse::Query`](https://www.modernistik.com/gems/parse-stack/Parse/Query.html) API reference.
1751
1770
 
@@ -1788,16 +1807,16 @@ Use on Pointer columns to return the full object. You may chain multiple columns
1788
1807
  ```
1789
1808
 
1790
1809
  #### :limit
1791
- Limit the number of objects returned by the query. The default is 100, with Parse allowing a maximum of 1000. The framework also allows a value of `:max`. Utilizing this will have the framework continually intelligently utilize `:skip` to continue to paginate through results until an empty result set is received or the `:skip` limit is reached (10,000). When utilizing `all()`, `:max` is the default option for `:limit`.
1810
+ Limit the number of objects returned by the query. The default is 100, with Parse allowing a maximum of 1000. The framework also allows a value of `:max`. Utilizing this will have the framework continually intelligently utilize `:skip` to continue to paginate through results until an empty result set is received or the `:skip` limit is reached. When utilizing `all()`, `:max` is the default option for `:limit`.
1792
1811
 
1793
1812
  ```ruby
1794
1813
  Song.all :limit => 1 # same as Song.first
1795
1814
  Song.all :limit => 1000 # maximum allowed by Parse
1796
- Song.all :limit => :max # up to 11,000 records (theoretical).
1815
+ Song.all :limit => :max
1797
1816
  ```
1798
1817
 
1799
1818
  #### :skip
1800
- Use with limit to paginate through results. Default is 0 with maximum value being 10,000.
1819
+ Use with limit to paginate through results. Default is 0.
1801
1820
 
1802
1821
  ```ruby
1803
1822
  # get the next 3 songs after the first 10
@@ -2153,6 +2172,30 @@ Equivalent to the `$geoWithin` Parse query operation and `$polygon` geopoint con
2153
2172
  SunkenShip.all :location.within_polygon => [bermuda, san_juan, miami]
2154
2173
  ```
2155
2174
 
2175
+ #### [Full Text Search Constraint](https://www.modernistik.com/gems/parse-stack/Parse/Constraint/FullTextSearchQueryConstraint.html)
2176
+ Equivalent to the `$text` Parse query operation and `$search` parameter constraint for efficient search capabilities. By creating indexes on one or more columns your strings are turned into tokens for full text search functionality. The `$search` key can take any number of parameters in hash form. *Requires Parse Server 2.5.0 or later*
2177
+
2178
+ ```ruby
2179
+ # Do a full text search on "anthony"
2180
+ q.where :field.text_search => "anthony"
2181
+
2182
+ # perform advance searches
2183
+ q.where :field.text_search => {term: "anthony", case_insensitive: true}
2184
+ # equivalent
2185
+ q.where :field.text_search => {:$term => "anthony", :$caseInsensitive => true}
2186
+ ```
2187
+
2188
+ You may use the following keys for the parameters clause.
2189
+
2190
+ | Parameter | Use |
2191
+ | :--- | :----- |
2192
+ | `$term` | Specify a field to search (**Required**)|
2193
+ | `$language` | Determines the list of stop words and the rules for tokenizer.|
2194
+ | `$caseSensitive` | Enable or disable case sensitive search.|
2195
+ | `$diacriticSensitive` | Enable or disable diacritic sensitive search.|
2196
+
2197
+ For additional details, please see [Query on String Values](https://docs.parseplatform.org/rest/guide/#queries-on-string-values).
2198
+
2156
2199
  ### Relational Queries
2157
2200
  Equivalent to the `$relatedTo` Parse query operation. If you want to retrieve objects that are members of a `Relation` field in your Parse class.
2158
2201
 
@@ -2615,7 +2658,7 @@ end
2615
2658
 
2616
2659
  ## Contributing
2617
2660
 
2618
- Bug reports and pull requests are welcome on GitHub at https://github.com/modernistik/parse-stack.
2661
+ Bug reports and pull requests are welcome on GitHub at [https://github.com/modernistik/parse-stack](https://github.com/modernistik/parse-stack).
2619
2662
 
2620
2663
  ## License
2621
2664
 
data/Rakefile CHANGED
@@ -1,11 +1,11 @@
1
1
  #!/usr/bin/env rake
2
2
  require "bundler/gem_tasks"
3
- require 'yard'
4
- require 'rake/testtask'
3
+ require "yard"
4
+ require "rake/testtask"
5
5
 
6
6
  Rake::TestTask.new do |t|
7
- t.libs << 'lib/parse/stack'
8
- t.test_files = FileList['test/lib/**/*_test.rb']
7
+ t.libs << "lib/parse/stack"
8
+ t.test_files = FileList["test/lib/**/*_test.rb"]
9
9
  t.warning = false
10
10
  t.verbose = true
11
11
  end
@@ -13,22 +13,22 @@ end
13
13
  task :default => :test
14
14
 
15
15
  task :console do
16
- exec './bin/console'
16
+ exec "./bin/console"
17
17
  end
18
18
  task :c => :console
19
19
 
20
- desc 'List undocumented methods'
21
- task 'yard:stats' do
22
- exec 'yard stats --list-undoc'
20
+ desc "List undocumented methods"
21
+ task "yard:stats" do
22
+ exec "yard stats --list-undoc"
23
23
  end
24
24
 
25
- desc 'Start the yard server'
26
- task 'docs' do
27
- exec 'rm -rf ./yard && yard server --reload'
25
+ desc "Start the yard server"
26
+ task "docs" do
27
+ exec "rm -rf ./yard && yard server --reload"
28
28
  end
29
29
 
30
30
  YARD::Rake::YardocTask.new do |t|
31
- t.files = ['lib/**/*.rb'] # optional
32
- t.options = ['-o', 'doc/parse-stack' ] # optional
33
- t.stats_options = ['--list-undoc'] # optional
31
+ t.files = ["lib/**/*.rb"] # optional
32
+ t.options = ["-o", "doc/parse-stack"] # optional
33
+ t.stats_options = ["--list-undoc"] # optional
34
34
  end
@@ -62,6 +62,7 @@ opt_parser = OptionParser.new do |o|
62
62
  file = File.read(filepath)
63
63
  config = JSON.parse file
64
64
  app = config["apps"].is_a?(Array) ? config["apps"].first : config["apps"]
65
+ app = config if app.nil? # uses parse-server config.json
65
66
  opts[:server_url] ||= app["serverURL"]
66
67
  opts[:app_id] ||= app["appId"]
67
68
  opts[:api_key] ||= app["restAPIKey"]
@@ -0,0 +1,59 @@
1
+ # encoding: UTF-8
2
+ # frozen_string_literal: true
3
+
4
+ require "active_support"
5
+ require "active_support/core_ext"
6
+ require_relative "./objects"
7
+
8
+ module Parse
9
+ module API
10
+ # REST API methods for fetching CRUD operations on Parse objects.
11
+ module Aggregate
12
+ # The class prefix for fetching objects.
13
+ # @!visibility private
14
+ PATH_PREFIX = "aggregate/"
15
+
16
+ # @!visibility private
17
+ PREFIX_MAP = Parse::API::Objects::PREFIX_MAP
18
+
19
+ # @!visibility private
20
+ def self.included(base)
21
+ base.extend(ClassMethods)
22
+ end
23
+
24
+ # Class methods to be applied to {Parse::Client}
25
+ module ClassMethods
26
+ # Get the aggregate API path for this class.
27
+ # @param className [String] the name of the Parse collection.
28
+ # @return [String] the API uri path
29
+ def aggregate_uri_path(className)
30
+ if className.is_a?(Parse::Pointer)
31
+ id = className.id
32
+ className = className.parse_class
33
+ end
34
+ "#{PATH_PREFIX}#{className}"
35
+ end
36
+ end
37
+
38
+ # Get the API path for this class.
39
+ # @param className [String] the name of the Parse collection.
40
+ # @return [String] the API uri path
41
+ def aggregate_uri_path(className)
42
+ self.class.aggregate_uri_path(className)
43
+ end
44
+
45
+ # Aggregate a set of matching objects for a query.
46
+ # @param className [String] the name of the Parse collection.
47
+ # @param query [Hash] The set of query constraints.
48
+ # @param opts [Hash] additional options to pass to the {Parse::Client} request.
49
+ # @param headers [Hash] additional HTTP headers to send with the request.
50
+ # @return [Parse::Response]
51
+ # @see Parse::Query
52
+ def aggregate_objects(className, query = {}, headers: {}, **opts)
53
+ response = request :get, aggregate_uri_path(className), query: query, headers: headers, opts: opts
54
+ response.parse_class = className if response.present?
55
+ response
56
+ end
57
+ end #Aggregate
58
+ end #API
59
+ end
@@ -1,8 +1,9 @@
1
1
  # encoding: UTF-8
2
2
  # frozen_string_literal: true
3
3
 
4
- require_relative '../client'
4
+ require_relative "../client"
5
5
  require_relative "analytics"
6
+ require_relative "aggregate"
6
7
  require_relative "batch"
7
8
  require_relative "config"
8
9
  require_relative "files"
@@ -2,7 +2,6 @@
2
2
  # frozen_string_literal: true
3
3
 
4
4
  module Parse
5
-
6
5
  module API
7
6
  # Defines the Analytics interface for the Parse REST API
8
7
  module Analytics
@@ -14,8 +13,6 @@ module Parse
14
13
  def send_analytics(event_name, metrics = {})
15
14
  request :post, "events/#{event_name}", body: metrics
16
15
  end
17
-
18
16
  end
19
17
  end
20
-
21
18
  end
@@ -1,12 +1,11 @@
1
1
  # encoding: UTF-8
2
2
  # frozen_string_literal: true
3
3
 
4
- require 'parallel'
5
- require 'active_support'
6
- require 'active_support/core_ext'
4
+ require "parallel"
5
+ require "active_support"
6
+ require "active_support/core_ext"
7
7
 
8
8
  module Parse
9
-
10
9
  module API
11
10
  # Defines the Batch interface for the Parse REST API
12
11
  # @see Parse::BatchOperation
@@ -30,7 +29,6 @@ module Parse
30
29
  response = request(:post, "batch", body: batch_operations.as_json)
31
30
  response.success? && response.batch? ? response.batch_responses : response
32
31
  end
33
-
34
32
  end
35
33
  end
36
34
  end
@@ -2,7 +2,6 @@
2
2
  # frozen_string_literal: true
3
3
 
4
4
  module Parse
5
-
6
5
  module API
7
6
  # Defines the CloudCode interface for the Parse REST API
8
7
  module CloudFunctions
@@ -22,8 +21,6 @@ module Parse
22
21
  def trigger_job(name, body = {})
23
22
  request :post, "jobs/#{name}", body: body
24
23
  end
25
-
26
24
  end
27
25
  end
28
-
29
26
  end
@@ -2,7 +2,6 @@
2
2
  # frozen_string_literal: true
3
3
 
4
4
  module Parse
5
-
6
5
  module API
7
6
  # Defines the Config interface for the Parse REST API
8
7
  module Config
@@ -44,9 +43,6 @@ module Parse
44
43
  @config.merge!(params) if result && @config.present?
45
44
  result
46
45
  end
47
-
48
46
  end
49
-
50
47
  end
51
-
52
48
  end
@@ -1,11 +1,10 @@
1
1
  # encoding: UTF-8
2
2
  # frozen_string_literal: true
3
3
 
4
- require 'active_support'
5
- require 'active_support/core_ext'
4
+ require "active_support"
5
+ require "active_support/core_ext"
6
6
 
7
7
  module Parse
8
-
9
8
  module API
10
9
  # Defines the Parse Files interface for the Parse REST API
11
10
  module Files
@@ -19,14 +18,11 @@ module Parse
19
18
  # @return [Parse::Response]
20
19
  def create_file(fileName, data = {}, content_type = nil)
21
20
  headers = {}
22
- headers.merge!( { Parse::Protocol::CONTENT_TYPE => content_type.to_s } ) if content_type.present?
21
+ headers.merge!({ Parse::Protocol::CONTENT_TYPE => content_type.to_s }) if content_type.present?
23
22
  response = request :post, "#{FILES_PATH}/#{fileName}", body: data, headers: headers
24
23
  response.parse_class = Parse::Model::TYPE_FILE
25
24
  response
26
25
  end
27
-
28
26
  end
29
-
30
27
  end
31
-
32
28
  end
@@ -2,8 +2,6 @@
2
2
  # frozen_string_literal: true
3
3
 
4
4
  module Parse
5
-
6
-
7
5
  module API
8
6
  # Defines the Parse webhooks interface for the Parse REST API
9
7
  module Hooks
@@ -23,7 +21,7 @@ module Parse
23
21
  # Fetch all defined cloud code functions.
24
22
  # @return [Parse::Response]
25
23
  def functions
26
- opts = {cache: false}
24
+ opts = { cache: false }
27
25
  request :get, "#{HOOKS_PREFIX}functions", opts: opts
28
26
  end
29
27
 
@@ -39,7 +37,7 @@ module Parse
39
37
  # @param url [String] the url endpoint for this cloud code function.
40
38
  # @return [Parse::Response]
41
39
  def create_function(functionName, url)
42
- request :post, "#{HOOKS_PREFIX}functions", body: {functionName: functionName, url: url}
40
+ request :post, "#{HOOKS_PREFIX}functions", body: { functionName: functionName, url: url }
43
41
  end
44
42
 
45
43
  # Updated the endpoint url for a registered cloud code webhook function.
@@ -62,7 +60,7 @@ module Parse
62
60
  # Get the set of registered triggers.
63
61
  # @return [Parse::Response]
64
62
  def triggers
65
- opts = {cache: false}
63
+ opts = { cache: false }
66
64
  request :get, "#{HOOKS_PREFIX}triggers", opts: opts
67
65
  end
68
66
 
@@ -84,7 +82,7 @@ module Parse
84
82
  # @see Parse::API::Hooks::TRIGGER_NAMES
85
83
  def create_trigger(triggerName, className, url)
86
84
  triggerName = _verify_trigger(triggerName)
87
- body = {className: className, triggerName: triggerName, url: url }
85
+ body = { className: className, triggerName: triggerName, url: url }
88
86
  request :post, "#{HOOKS_PREFIX}triggers", body: body
89
87
  end
90
88
 
@@ -108,8 +106,6 @@ module Parse
108
106
  triggerName = _verify_trigger(triggerName)
109
107
  request :put, "#{HOOKS_PREFIX}triggers/#{className}/#{triggerName}", body: { __op: "Delete" }
110
108
  end
111
-
112
109
  end
113
110
  end
114
-
115
111
  end