parse-stack 1.8.0 → 1.8.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (82) hide show
  1. checksums.yaml +4 -4
  2. data/.solargraph.yml +23 -0
  3. data/.travis.yml +0 -1
  4. data/Gemfile +13 -12
  5. data/Gemfile.lock +88 -51
  6. data/README.md +2 -4
  7. data/Rakefile +14 -14
  8. data/lib/parse/api/aggregate.rb +4 -7
  9. data/lib/parse/api/all.rb +1 -1
  10. data/lib/parse/api/analytics.rb +0 -3
  11. data/lib/parse/api/batch.rb +3 -5
  12. data/lib/parse/api/cloud_functions.rb +0 -3
  13. data/lib/parse/api/config.rb +0 -4
  14. data/lib/parse/api/files.rb +3 -7
  15. data/lib/parse/api/hooks.rb +4 -8
  16. data/lib/parse/api/objects.rb +7 -12
  17. data/lib/parse/api/push.rb +0 -4
  18. data/lib/parse/api/schema.rb +2 -6
  19. data/lib/parse/api/server.rb +4 -7
  20. data/lib/parse/api/sessions.rb +2 -5
  21. data/lib/parse/api/users.rb +9 -14
  22. data/lib/parse/client.rb +54 -50
  23. data/lib/parse/client/authentication.rb +29 -33
  24. data/lib/parse/client/batch.rb +8 -11
  25. data/lib/parse/client/body_builder.rb +19 -20
  26. data/lib/parse/client/caching.rb +23 -28
  27. data/lib/parse/client/protocol.rb +11 -12
  28. data/lib/parse/client/request.rb +4 -6
  29. data/lib/parse/client/response.rb +5 -7
  30. data/lib/parse/model/acl.rb +14 -12
  31. data/lib/parse/model/associations/belongs_to.rb +14 -21
  32. data/lib/parse/model/associations/collection_proxy.rb +328 -329
  33. data/lib/parse/model/associations/has_many.rb +18 -25
  34. data/lib/parse/model/associations/has_one.rb +6 -11
  35. data/lib/parse/model/associations/pointer_collection_proxy.rb +5 -8
  36. data/lib/parse/model/associations/relation_collection_proxy.rb +5 -9
  37. data/lib/parse/model/bytes.rb +8 -10
  38. data/lib/parse/model/classes/installation.rb +2 -4
  39. data/lib/parse/model/classes/product.rb +2 -5
  40. data/lib/parse/model/classes/role.rb +3 -5
  41. data/lib/parse/model/classes/session.rb +2 -5
  42. data/lib/parse/model/classes/user.rb +20 -16
  43. data/lib/parse/model/core/actions.rb +31 -46
  44. data/lib/parse/model/core/builder.rb +6 -6
  45. data/lib/parse/model/core/errors.rb +0 -1
  46. data/lib/parse/model/core/fetching.rb +45 -50
  47. data/lib/parse/model/core/properties.rb +51 -66
  48. data/lib/parse/model/core/querying.rb +291 -294
  49. data/lib/parse/model/core/schema.rb +89 -92
  50. data/lib/parse/model/date.rb +16 -17
  51. data/lib/parse/model/file.rb +171 -174
  52. data/lib/parse/model/geopoint.rb +12 -16
  53. data/lib/parse/model/model.rb +31 -37
  54. data/lib/parse/model/object.rb +47 -53
  55. data/lib/parse/model/pointer.rb +177 -176
  56. data/lib/parse/model/push.rb +8 -10
  57. data/lib/parse/model/shortnames.rb +1 -2
  58. data/lib/parse/model/time_zone.rb +3 -5
  59. data/lib/parse/query.rb +34 -35
  60. data/lib/parse/query/constraint.rb +4 -6
  61. data/lib/parse/query/constraints.rb +21 -29
  62. data/lib/parse/query/operation.rb +8 -11
  63. data/lib/parse/query/ordering.rb +45 -49
  64. data/lib/parse/stack.rb +11 -12
  65. data/lib/parse/stack/generators/rails.rb +28 -30
  66. data/lib/parse/stack/generators/templates/model.erb +5 -6
  67. data/lib/parse/stack/generators/templates/model_installation.rb +0 -1
  68. data/lib/parse/stack/generators/templates/model_role.rb +0 -1
  69. data/lib/parse/stack/generators/templates/model_session.rb +0 -1
  70. data/lib/parse/stack/generators/templates/model_user.rb +0 -1
  71. data/lib/parse/stack/generators/templates/parse.rb +9 -9
  72. data/lib/parse/stack/generators/templates/webhooks.rb +1 -2
  73. data/lib/parse/stack/railtie.rb +2 -4
  74. data/lib/parse/stack/tasks.rb +70 -86
  75. data/lib/parse/stack/version.rb +1 -1
  76. data/lib/parse/webhooks.rb +19 -26
  77. data/lib/parse/webhooks/payload.rb +26 -28
  78. data/lib/parse/webhooks/registration.rb +23 -31
  79. data/parse-stack.gemspec +25 -25
  80. data/parse-stack.png +0 -0
  81. metadata +13 -7
  82. data/.github/parse-ruby-sdk.png +0 -0
@@ -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
@@ -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
  # REST API methods for fetching CRUD operations on Parse objects.
11
10
  module Objects
@@ -15,10 +14,9 @@ module Parse
15
14
 
16
15
  # @!visibility private
17
16
  PREFIX_MAP = { installation: "installations", _installation: "installations",
18
- user: "users", _user: "users",
19
- role: "roles", _role: "roles",
20
- session: "sessions", _session: "sessions"
21
- }.freeze
17
+ user: "users", _user: "users",
18
+ role: "roles", _role: "roles",
19
+ session: "sessions", _session: "sessions" }.freeze
22
20
 
23
21
  # @!visibility private
24
22
  def self.included(base)
@@ -43,7 +41,6 @@ module Parse
43
41
  end
44
42
  id.present? ? "#{uri}/#{id}" : "#{uri}/"
45
43
  end
46
-
47
44
  end
48
45
 
49
46
  # Get the API path for this class.
@@ -61,7 +58,7 @@ module Parse
61
58
  # @param headers [Hash] additional HTTP headers to send with the request.
62
59
  # @return [Parse::Response]
63
60
  def create_object(className, body = {}, headers: {}, **opts)
64
- response = request :post, uri_path(className) , body: body, headers: headers, opts: opts
61
+ response = request :post, uri_path(className), body: body, headers: headers, opts: opts
65
62
  response.parse_class = className if response.present?
66
63
  response
67
64
  end
@@ -111,12 +108,10 @@ module Parse
111
108
  # @param headers [Hash] additional HTTP headers to send with the request.
112
109
  # @return [Parse::Response]
113
110
  def update_object(className, id, body = {}, headers: {}, **opts)
114
- response = request :put, uri_path(className,id) , body: body, headers: headers, opts: opts
111
+ response = request :put, uri_path(className, id), body: body, headers: headers, opts: opts
115
112
  response.parse_class = className if response.present?
116
113
  response
117
114
  end
118
-
119
115
  end #Objects
120
116
  end #API
121
-
122
117
  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 Parse Push notification service interface for the Parse REST API
8
7
  module Push
@@ -16,9 +15,6 @@ module Parse
16
15
  def push(payload = {})
17
16
  request :post, PUSH_PATH, body: payload.as_json
18
17
  end
19
-
20
18
  end
21
-
22
19
  end
23
-
24
20
  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 Schema interface for the Parse REST API
8
7
  module Schema
@@ -12,7 +11,7 @@ module Parse
12
11
  # Get all the schemas for the application.
13
12
  # @return [Parse::Response]
14
13
  def schemas
15
- opts = {cache: false}
14
+ opts = { cache: false }
16
15
  request :get, SCHEMAS_PATH, opts: opts
17
16
  end
18
17
 
@@ -20,7 +19,7 @@ module Parse
20
19
  # @param className [String] the name of the remote Parse collection.
21
20
  # @return [Parse::Response]
22
21
  def schema(className)
23
- opts = {cache: false}
22
+ opts = { cache: false }
24
23
  request :get, "#{SCHEMAS_PATH}/#{className}", opts: opts
25
24
  end
26
25
 
@@ -41,9 +40,6 @@ module Parse
41
40
  def update_schema(className, schema)
42
41
  request :put, "#{SCHEMAS_PATH}/#{className}", body: schema
43
42
  end
44
-
45
43
  end #Schema
46
-
47
44
  end #API
48
-
49
45
  end
@@ -2,7 +2,6 @@
2
2
  # frozen_string_literal: true
3
3
 
4
4
  module Parse
5
-
6
5
  module API
7
6
  # APIs related to the open source Parse Server.
8
7
  module Server
@@ -12,9 +11,9 @@ module Parse
12
11
  attr_accessor :server_info
13
12
 
14
13
  # @!visibility private
15
- SERVER_INFO_PATH = 'serverInfo'
14
+ SERVER_INFO_PATH = "serverInfo"
16
15
  # @!visibility private
17
- SERVER_HEALTH_PATH = 'health'
16
+ SERVER_HEALTH_PATH = "health"
18
17
  # Fetch and cache information about the Parse server configuration. This
19
18
  # hash contains information specifically to the configuration of the running
20
19
  # parse server.
@@ -23,13 +22,13 @@ module Parse
23
22
  return @server_info if @server_info.present?
24
23
  response = request :get, SERVER_INFO_PATH
25
24
  @server_info = response.error? ? nil :
26
- response.result.with_indifferent_access
25
+ response.result.with_indifferent_access
27
26
  end
28
27
 
29
28
  # Fetches the status of the server based on the health check.
30
29
  # @return [Boolean] whether the server is 'OK'.
31
30
  def server_health
32
- opts = {cache: false}
31
+ opts = { cache: false }
33
32
  response = request :get, SERVER_HEALTH_PATH, opts: opts
34
33
  response.success?
35
34
  end
@@ -46,8 +45,6 @@ module Parse
46
45
  def server_version
47
46
  server_info.present? ? @server_info[:parseServerVersion] : nil
48
47
  end
49
-
50
48
  end
51
49
  end
52
-
53
50
  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 Session class interface for the Parse REST API
8
7
  module Sessions
@@ -14,14 +13,12 @@ module Parse
14
13
  # @param opts [Hash] additional options to pass to the {Parse::Client} request.
15
14
  # @return [Parse::Response]
16
15
  def fetch_session(session_token, **opts)
17
- opts.merge!({use_master_key: false, cache: false})
18
- headers = {Parse::Protocol::SESSION_TOKEN => session_token}
16
+ opts.merge!({ use_master_key: false, cache: false })
17
+ headers = { Parse::Protocol::SESSION_TOKEN => session_token }
19
18
  response = request :get, "#{SESSION_PATH_PREFIX}/me", headers: headers, opts: opts
20
19
  response.parse_class = Parse::Model::CLASS_SESSION
21
20
  response
22
21
  end
23
-
24
22
  end
25
23
  end
26
-
27
24
  end
@@ -1,10 +1,9 @@
1
1
  # encoding: UTF-8
2
2
  # frozen_string_literal: true
3
3
 
4
- require 'open-uri'
4
+ require "open-uri"
5
5
 
6
6
  module Parse
7
-
8
7
  module API
9
8
  # Defines the User class interface for the Parse REST API
10
9
  module Users
@@ -42,7 +41,7 @@ module Parse
42
41
  # @param headers [Hash] additional HTTP headers to send with the request.
43
42
  # @return [Parse::Response]
44
43
  def current_user(session_token, headers: {}, **opts)
45
- headers.merge!({Parse::Protocol::SESSION_TOKEN => session_token})
44
+ headers.merge!({ Parse::Protocol::SESSION_TOKEN => session_token })
46
45
  response = request :get, "#{USER_PATH_PREFIX}/me", headers: headers, opts: opts
47
46
  response.parse_class = Parse::Model::CLASS_USER
48
47
  response
@@ -54,9 +53,9 @@ module Parse
54
53
  # @param headers [Hash] additional HTTP headers to send with the request.
55
54
  # @return [Parse::Response]
56
55
  def create_user(body, headers: {}, **opts)
57
- headers.merge!({ Parse::Protocol::REVOCABLE_SESSION => '1'})
56
+ headers.merge!({ Parse::Protocol::REVOCABLE_SESSION => "1" })
58
57
  if opts[:session_token].present?
59
- headers.merge!({ Parse::Protocol::SESSION_TOKEN => opts[:session_token]})
58
+ headers.merge!({ Parse::Protocol::SESSION_TOKEN => opts[:session_token] })
60
59
  end
61
60
  response = request :post, USER_PATH_PREFIX, body: body, headers: headers, opts: opts
62
61
  response.parse_class = Parse::Model::CLASS_USER
@@ -102,8 +101,8 @@ module Parse
102
101
  # @param opts [Hash] additional options to pass to the {Parse::Client} request.
103
102
  # @param headers [Hash] additional HTTP headers to send with the request.
104
103
  # @return [Parse::Response]
105
- def request_password_reset(email, headers: {}, **opts)
106
- body = {email: email}
104
+ def request_password_reset(email, headers: {}, **opts)
105
+ body = { email: email }
107
106
  request :post, REQUEST_PASSWORD_RESET, body: body, opts: opts, headers: headers
108
107
  end
109
108
 
@@ -116,7 +115,7 @@ module Parse
116
115
  def login(username, password, headers: {}, **opts)
117
116
  # Probably pass Installation-ID as header
118
117
  query = { username: username, password: password }
119
- headers.merge!({ Parse::Protocol::REVOCABLE_SESSION => '1'})
118
+ headers.merge!({ Parse::Protocol::REVOCABLE_SESSION => "1" })
120
119
  # headers.merge!( { Parse::Protocol::INSTALLATION_ID => ''} )
121
120
  response = request :get, LOGIN_PATH, query: query, headers: headers, opts: opts
122
121
  response.parse_class = Parse::Model::CLASS_USER
@@ -129,8 +128,8 @@ module Parse
129
128
  # @param opts [Hash] additional options to pass to the {Parse::Client} request.
130
129
  # @return [Parse::Response]
131
130
  def logout(session_token, headers: {}, **opts)
132
- headers.merge!({ Parse::Protocol::SESSION_TOKEN => session_token})
133
- opts.merge!({use_master_key: false, session_token: session_token})
131
+ headers.merge!({ Parse::Protocol::SESSION_TOKEN => session_token })
132
+ opts.merge!({ use_master_key: false, session_token: session_token })
134
133
  request :post, LOGOUT_PATH, headers: headers, opts: opts
135
134
  end
136
135
 
@@ -146,10 +145,6 @@ module Parse
146
145
  body[:email] = email || body[:email]
147
146
  create_user(body, opts)
148
147
  end
149
-
150
-
151
148
  end # Users
152
-
153
149
  end #API
154
-
155
150
  end #Parse
@@ -1,15 +1,15 @@
1
- require 'faraday'
2
- require 'faraday_middleware'
3
- require 'active_support'
4
- require 'moneta'
5
- require 'active_model_serializers'
6
- require 'active_support/inflector'
7
- require 'active_support/core_ext/object'
8
- require 'active_support/core_ext/string'
9
- require 'active_support/core_ext/date/calculations'
10
- require 'active_support/core_ext/date_time/calculations'
11
- require 'active_support/core_ext/time/calculations'
12
- require 'active_support/core_ext'
1
+ require "faraday"
2
+ require "faraday_middleware"
3
+ require "active_support"
4
+ require "moneta"
5
+ require "active_model_serializers"
6
+ require "active_support/inflector"
7
+ require "active_support/core_ext/object"
8
+ require "active_support/core_ext/string"
9
+ require "active_support/core_ext/date/calculations"
10
+ require "active_support/core_ext/date_time/calculations"
11
+ require "active_support/core_ext/time/calculations"
12
+ require "active_support/core_ext"
13
13
  require_relative "client/request"
14
14
  require_relative "client/response"
15
15
  require_relative "client/batch"
@@ -21,21 +21,28 @@ require_relative "api/all"
21
21
  module Parse
22
22
  class Error < StandardError
23
23
  # An error when a general connection occurs.
24
- class ConnectionError < Error; end;
24
+ class ConnectionError < Error; end
25
+
25
26
  # An error when a connection timeout occurs.
26
- class TimeoutError < Error; end;
27
+ class TimeoutError < Error; end
28
+
27
29
  # An error when there is an Parse REST API protocol error.
28
- class ProtocolError < Error; end;
30
+ class ProtocolError < Error; end
31
+
29
32
  # An error when the Parse server returned invalid code.
30
- class ServerError < Error; end;
33
+ class ServerError < Error; end
34
+
31
35
  # An error when a Parse server responds with HTTP 500.
32
- class ServiceUnavailableError < Error; end;
36
+ class ServiceUnavailableError < Error; end
37
+
33
38
  # An error when the authentication credentials in the request are invalid.
34
- class AuthenticationError < Error; end;
39
+ class AuthenticationError < Error; end
40
+
35
41
  # An error when the burst limit has been exceeded.
36
- class RequestLimitExceededError < Error; end;
42
+ class RequestLimitExceededError < Error; end
43
+
37
44
  # An error when the session token provided in the request is invalid.
38
- class InvalidSessionTokenError < Error; end;
45
+ class InvalidSessionTokenError < Error; end
39
46
  end
40
47
 
41
48
  # Retrieve the App specific Parse configuration parameters. The configuration
@@ -129,7 +136,7 @@ module Parse
129
136
  RETRY_DELAY = 1.5
130
137
 
131
138
  # An error when a general response error occurs when communicating with Parse server.
132
- class ResponseError < Parse::Error; end;
139
+ class ResponseError < Parse::Error; end
133
140
 
134
141
  # @!attribute cache
135
142
  # The underlying cache store for caching API requests.
@@ -198,7 +205,6 @@ module Parse
198
205
  def setup(opts = {})
199
206
  @clients[:default] = self.new(opts, &Proc.new)
200
207
  end
201
-
202
208
  end
203
209
 
204
210
  # Create a new client connected to the Parse Server REST API endpoint.
@@ -242,16 +248,16 @@ module Parse
242
248
  # @see Parse::Middleware::Authentication
243
249
  # @see Parse::Protocol
244
250
  def initialize(opts = {})
245
- @server_url = opts[:server_url] || ENV["PARSE_SERVER_URL"] || Parse::Protocol::SERVER_URL
246
- @application_id = opts[:application_id] || opts[:app_id] || ENV["PARSE_SERVER_APPLICATION_ID"] || ENV['PARSE_APP_ID']
247
- @api_key = opts[:api_key] || opts[:rest_api_key] || ENV["PARSE_SERVER_REST_API_KEY"] || ENV["PARSE_API_KEY"]
248
- @master_key = opts[:master_key] || ENV['PARSE_SERVER_MASTER_KEY'] || ENV["PARSE_MASTER_KEY"]
251
+ @server_url = opts[:server_url] || ENV["PARSE_SERVER_URL"] || Parse::Protocol::SERVER_URL
252
+ @application_id = opts[:application_id] || opts[:app_id] || ENV["PARSE_SERVER_APPLICATION_ID"] || ENV["PARSE_APP_ID"]
253
+ @api_key = opts[:api_key] || opts[:rest_api_key] || ENV["PARSE_SERVER_REST_API_KEY"] || ENV["PARSE_API_KEY"]
254
+ @master_key = opts[:master_key] || ENV["PARSE_SERVER_MASTER_KEY"] || ENV["PARSE_MASTER_KEY"]
249
255
  opts[:adapter] ||= Faraday.default_adapter
250
256
  opts[:expires] ||= 3
251
- if @server_url.nil? || @application_id.nil? || ( @api_key.nil? && @master_key.nil? )
257
+ if @server_url.nil? || @application_id.nil? || (@api_key.nil? && @master_key.nil?)
252
258
  raise Parse::Error::ConnectionError, "Please call Parse.setup(server_url:, application_id:, api_key:) to setup a client"
253
259
  end
254
- @server_url += '/' unless @server_url.ends_with?('/')
260
+ @server_url += "/" unless @server_url.ends_with?("/")
255
261
  #Configure Faraday
256
262
  opts[:faraday] ||= {}
257
263
  opts[:faraday].merge!(:url => @server_url)
@@ -267,9 +273,9 @@ module Parse
267
273
  # so that other middlewares have access to the env that is being set by
268
274
  # this middleware. First added is first to brocess.
269
275
  conn.use Parse::Middleware::Authentication,
270
- application_id: @application_id,
271
- master_key: @master_key,
272
- api_key: @api_key
276
+ application_id: @application_id,
277
+ master_key: @master_key,
278
+ api_key: @api_key
273
279
  # This middleware turns the result from Parse into a Parse::Response object
274
280
  # and making sure request that are going out, follow the proper MIME format.
275
281
  # We place it after the Authentication middleware in case we need to use then
@@ -294,13 +300,12 @@ module Parse
294
300
  raise ArgumentError, "Parse::Client option :cache needs to be a type of Moneta store"
295
301
  end
296
302
  self.cache = opts[:cache]
297
- conn.use Parse::Middleware::Caching, self.cache, {expires: opts[:expires].to_i }
303
+ conn.use Parse::Middleware::Caching, self.cache, { expires: opts[:expires].to_i }
298
304
  end
299
305
 
300
306
  yield(conn) if block_given?
301
307
 
302
308
  conn.adapter opts[:adapter]
303
-
304
309
  end
305
310
  Parse::Client.clients[:default] ||= self
306
311
  end
@@ -383,11 +388,11 @@ module Parse
383
388
  # if the first argument is a Parse::Request object, then construct it
384
389
  _request = nil
385
390
  if method.is_a?(Request)
386
- _request = method
387
- method = _request.method
388
- uri ||= _request.path
389
- query ||= _request.query
390
- body ||= _request.body
391
+ _request = method
392
+ method = _request.method
393
+ uri ||= _request.path
394
+ query ||= _request.query
395
+ body ||= _request.body
391
396
  headers.merge! _request.headers
392
397
  else
393
398
  _request = Parse::Request.new(method, uri, body: body, headers: headers, opts: opts)
@@ -471,7 +476,7 @@ module Parse
471
476
  warn "[Parse:Retry] Retries remaining #{_retry_count} : #{response.request}"
472
477
  _retry_count -= 1
473
478
  backoff_delay = RETRY_DELAY * (self.retry_limit - _retry_count)
474
- _retry_delay = [0,RETRY_DELAY, backoff_delay].sample
479
+ _retry_delay = [0, RETRY_DELAY, backoff_delay].sample
475
480
  sleep _retry_delay if _retry_delay > 0
476
481
  retry
477
482
  end
@@ -481,7 +486,7 @@ module Parse
481
486
  warn "[Parse:Retry] Retries remaining #{_retry_count} : #{_request}"
482
487
  _retry_count -= 1
483
488
  backoff_delay = RETRY_DELAY * (self.retry_limit - _retry_count)
484
- _retry_delay = [0,RETRY_DELAY, backoff_delay].sample
489
+ _retry_delay = [0, RETRY_DELAY, backoff_delay].sample
485
490
  sleep _retry_delay if _retry_delay > 0
486
491
  retry
487
492
  end
@@ -502,7 +507,7 @@ module Parse
502
507
  # @param body [Hash] a hash that will be JSON encoded for the body of this request.
503
508
  # @param headers (see #get)
504
509
  # @return (see #request)
505
- def post(uri, body = nil, headers = {} )
510
+ def post(uri, body = nil, headers = {})
506
511
  request :post, uri, body: body, headers: headers
507
512
  end
508
513
 
@@ -547,18 +552,18 @@ module Parse
547
552
  # a the default {Parse::Client} instance.
548
553
  module ClassMethods
549
554
 
550
- # @return [Parse::Client] the current client for :default.
551
- attr_accessor :client
552
- def client
553
- @client ||= Parse::Client.client #defaults to :default tag
554
- end
555
+ # @return [Parse::Client] the current client for :default.
556
+ attr_accessor :client
557
+
558
+ def client
559
+ @client ||= Parse::Client.client #defaults to :default tag
560
+ end
555
561
  end
556
562
 
557
563
  # @return [Parse::Client] the current client defined for the class.
558
564
  def client
559
565
  self.class.client
560
566
  end
561
-
562
567
  end #Connectable
563
568
  end
564
569
 
@@ -588,7 +593,7 @@ module Parse
588
593
  # @param opts (see Parse.call_function)
589
594
  # @return (see Parse.call_function)
590
595
  def self.trigger_job(name, body = {}, **opts)
591
- conn = opts[:session] || opts[:client] || :default
596
+ conn = opts[:session] || opts[:client] || :default
592
597
  response = Parse::Client.client(conn).trigger_job(name, body)
593
598
  return response if opts[:raw].present?
594
599
  response.error? ? nil : response.result["result"]
@@ -600,10 +605,9 @@ module Parse
600
605
  # @param opts [Hash] additional options.
601
606
  # @return [Object] the result data of the response. nil if there was an error.
602
607
  def self.call_function(name, body = {}, **opts)
603
- conn = opts[:session] || opts[:client] || :default
608
+ conn = opts[:session] || opts[:client] || :default
604
609
  response = Parse::Client.client(conn).call_function(name, body)
605
610
  return response if opts[:raw].present?
606
611
  response.error? ? nil : response.result["result"]
607
612
  end
608
-
609
613
  end