parse-stack 1.8.0 → 1.8.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.solargraph.yml +23 -0
- data/.travis.yml +0 -1
- data/Gemfile +13 -12
- data/Gemfile.lock +88 -51
- data/README.md +2 -4
- data/Rakefile +14 -14
- data/lib/parse/api/aggregate.rb +4 -7
- data/lib/parse/api/all.rb +1 -1
- data/lib/parse/api/analytics.rb +0 -3
- data/lib/parse/api/batch.rb +3 -5
- data/lib/parse/api/cloud_functions.rb +0 -3
- data/lib/parse/api/config.rb +0 -4
- data/lib/parse/api/files.rb +3 -7
- data/lib/parse/api/hooks.rb +4 -8
- data/lib/parse/api/objects.rb +7 -12
- data/lib/parse/api/push.rb +0 -4
- data/lib/parse/api/schema.rb +2 -6
- data/lib/parse/api/server.rb +4 -7
- data/lib/parse/api/sessions.rb +2 -5
- data/lib/parse/api/users.rb +9 -14
- data/lib/parse/client.rb +54 -50
- data/lib/parse/client/authentication.rb +29 -33
- data/lib/parse/client/batch.rb +8 -11
- data/lib/parse/client/body_builder.rb +19 -20
- data/lib/parse/client/caching.rb +23 -28
- data/lib/parse/client/protocol.rb +11 -12
- data/lib/parse/client/request.rb +4 -6
- data/lib/parse/client/response.rb +5 -7
- data/lib/parse/model/acl.rb +14 -12
- data/lib/parse/model/associations/belongs_to.rb +14 -21
- data/lib/parse/model/associations/collection_proxy.rb +328 -329
- data/lib/parse/model/associations/has_many.rb +18 -25
- data/lib/parse/model/associations/has_one.rb +6 -11
- data/lib/parse/model/associations/pointer_collection_proxy.rb +5 -8
- data/lib/parse/model/associations/relation_collection_proxy.rb +5 -9
- data/lib/parse/model/bytes.rb +8 -10
- data/lib/parse/model/classes/installation.rb +2 -4
- data/lib/parse/model/classes/product.rb +2 -5
- data/lib/parse/model/classes/role.rb +3 -5
- data/lib/parse/model/classes/session.rb +2 -5
- data/lib/parse/model/classes/user.rb +20 -16
- data/lib/parse/model/core/actions.rb +31 -46
- data/lib/parse/model/core/builder.rb +6 -6
- data/lib/parse/model/core/errors.rb +0 -1
- data/lib/parse/model/core/fetching.rb +45 -50
- data/lib/parse/model/core/properties.rb +51 -66
- data/lib/parse/model/core/querying.rb +291 -294
- data/lib/parse/model/core/schema.rb +89 -92
- data/lib/parse/model/date.rb +16 -17
- data/lib/parse/model/file.rb +171 -174
- data/lib/parse/model/geopoint.rb +12 -16
- data/lib/parse/model/model.rb +31 -37
- data/lib/parse/model/object.rb +47 -53
- data/lib/parse/model/pointer.rb +177 -176
- data/lib/parse/model/push.rb +8 -10
- data/lib/parse/model/shortnames.rb +1 -2
- data/lib/parse/model/time_zone.rb +3 -5
- data/lib/parse/query.rb +34 -35
- data/lib/parse/query/constraint.rb +4 -6
- data/lib/parse/query/constraints.rb +21 -29
- data/lib/parse/query/operation.rb +8 -11
- data/lib/parse/query/ordering.rb +45 -49
- data/lib/parse/stack.rb +11 -12
- data/lib/parse/stack/generators/rails.rb +28 -30
- data/lib/parse/stack/generators/templates/model.erb +5 -6
- data/lib/parse/stack/generators/templates/model_installation.rb +0 -1
- data/lib/parse/stack/generators/templates/model_role.rb +0 -1
- data/lib/parse/stack/generators/templates/model_session.rb +0 -1
- data/lib/parse/stack/generators/templates/model_user.rb +0 -1
- data/lib/parse/stack/generators/templates/parse.rb +9 -9
- data/lib/parse/stack/generators/templates/webhooks.rb +1 -2
- data/lib/parse/stack/railtie.rb +2 -4
- data/lib/parse/stack/tasks.rb +70 -86
- data/lib/parse/stack/version.rb +1 -1
- data/lib/parse/webhooks.rb +19 -26
- data/lib/parse/webhooks/payload.rb +26 -28
- data/lib/parse/webhooks/registration.rb +23 -31
- data/parse-stack.gemspec +25 -25
- data/parse-stack.png +0 -0
- metadata +13 -7
- data/.github/parse-ruby-sdk.png +0 -0
@@ -1,13 +1,12 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
|
-
require_relative
|
5
|
-
require_relative
|
6
|
-
require_relative
|
7
|
-
require_relative
|
4
|
+
require_relative "../pointer"
|
5
|
+
require_relative "collection_proxy"
|
6
|
+
require_relative "pointer_collection_proxy"
|
7
|
+
require_relative "relation_collection_proxy"
|
8
8
|
|
9
9
|
module Parse
|
10
|
-
|
11
10
|
module Associations
|
12
11
|
|
13
12
|
# Parse has many ways to implement one-to-many and many-to-many
|
@@ -325,9 +324,11 @@ module Parse
|
|
325
324
|
# @!visibility private
|
326
325
|
module ClassMethods
|
327
326
|
attr_accessor :relations
|
327
|
+
|
328
328
|
def relations
|
329
329
|
@relations ||= {}
|
330
330
|
end
|
331
|
+
|
331
332
|
# Examples:
|
332
333
|
# has_many :fans, as: :users, through: :relation, field: "awesomeFans"
|
333
334
|
# has_many :songs
|
@@ -353,7 +354,7 @@ module Parse
|
|
353
354
|
# the remote class is either key or as.
|
354
355
|
opts[:scope_only] ||= false
|
355
356
|
klassName = (opts[:as] || key).to_parse_class singularize: true
|
356
|
-
foreign_field = (opts[:field] || parse_class.columnize
|
357
|
+
foreign_field = (opts[:field] || parse_class.columnize).to_sym
|
357
358
|
|
358
359
|
define_method(key) do |*args, &block|
|
359
360
|
return [] if @id.nil?
|
@@ -372,7 +373,7 @@ module Parse
|
|
372
373
|
query.instance_exec(&scope)
|
373
374
|
query.conditions(*args) if args.present?
|
374
375
|
else
|
375
|
-
query.instance_exec(*args
|
376
|
+
query.instance_exec(*args, &scope)
|
376
377
|
end
|
377
378
|
instance = nil # help clean up ruby gc
|
378
379
|
elsif args.present?
|
@@ -383,11 +384,10 @@ module Parse
|
|
383
384
|
klass = Parse::Model.find_class klassName
|
384
385
|
|
385
386
|
if klass.present? && klass.respond_to?(m)
|
386
|
-
|
387
387
|
klass_scope = klass.send(m, *args) # blocks only passed to final result set
|
388
388
|
return klass_scope unless klass_scope.is_a?(Parse::Query)
|
389
389
|
# merge constraints
|
390
|
-
add_constraints(
|
390
|
+
add_constraints(klass_scope.constraints)
|
391
391
|
# if a block was passed, execute the query, otherwise return the query
|
392
392
|
return chained_block.present? ? results(&chained_block) : self
|
393
393
|
end
|
@@ -399,7 +399,6 @@ module Parse
|
|
399
399
|
return query if block.nil?
|
400
400
|
query.results(&block)
|
401
401
|
end
|
402
|
-
|
403
402
|
end
|
404
403
|
|
405
404
|
# Define a one-to-many or many-to-many association between the local model and a foreign class.
|
@@ -412,9 +411,10 @@ module Parse
|
|
412
411
|
|
413
412
|
# below this is the same
|
414
413
|
opts.reverse_merge!({
|
415
|
-
|
416
|
-
|
417
|
-
|
414
|
+
field: key.to_s.camelize(:lower),
|
415
|
+
required: false,
|
416
|
+
as: key,
|
417
|
+
})
|
418
418
|
|
419
419
|
klassName = opts[:as].to_parse_class singularize: true
|
420
420
|
parse_field = opts[:field].to_sym # name of the column (local or remote)
|
@@ -446,12 +446,12 @@ module Parse
|
|
446
446
|
proxyKlass = Parse::RelationCollectionProxy
|
447
447
|
self.relations[key] = klassName
|
448
448
|
else
|
449
|
-
self.attributes.merge!(
|
449
|
+
self.attributes.merge!(parse_field => :array)
|
450
450
|
# Add them to the list of fields in our class model
|
451
|
-
self.fields.merge!(
|
451
|
+
self.fields.merge!(key => :array, parse_field => :array)
|
452
452
|
end
|
453
453
|
|
454
|
-
self.field_map.merge!(
|
454
|
+
self.field_map.merge!(key => parse_field)
|
455
455
|
# dirty tracking
|
456
456
|
define_attribute_methods key
|
457
457
|
|
@@ -476,7 +476,7 @@ module Parse
|
|
476
476
|
|
477
477
|
# proxy setter that forwards with dirty tracking
|
478
478
|
define_method("#{key}=") do |val|
|
479
|
-
|
479
|
+
send set_attribute_method, val, true
|
480
480
|
end
|
481
481
|
|
482
482
|
# This will set the content of the proxy.
|
@@ -510,7 +510,7 @@ module Parse
|
|
510
510
|
|
511
511
|
# send dirty tracking if set
|
512
512
|
if track == true
|
513
|
-
send will_change_method unless val == instance_variable_get(
|
513
|
+
send will_change_method unless val == instance_variable_get(ivar)
|
514
514
|
end
|
515
515
|
# TODO: Only allow empty proxy collection class as a value or nil.
|
516
516
|
if val.is_a?(Parse::CollectionProxy)
|
@@ -518,7 +518,6 @@ module Parse
|
|
518
518
|
else
|
519
519
|
warn "[#{self.class}] Invalid value #{val} for :has_many field #{key}. Should be an Array or a CollectionProxy"
|
520
520
|
end
|
521
|
-
|
522
521
|
end
|
523
522
|
|
524
523
|
data_type = opts[:through]
|
@@ -535,7 +534,6 @@ module Parse
|
|
535
534
|
q = self.send :"#{key}_relation_query"
|
536
535
|
q.results || []
|
537
536
|
end
|
538
|
-
|
539
537
|
end
|
540
538
|
|
541
539
|
# if the remote field name and the local field name are the same
|
@@ -549,8 +547,6 @@ module Parse
|
|
549
547
|
elsif parse_field.to_sym != :objectId
|
550
548
|
warn "Alias has_many method #{self}##{parse_field} already defined."
|
551
549
|
end
|
552
|
-
|
553
|
-
|
554
550
|
end # has_many_array
|
555
551
|
end #ClassMethods
|
556
552
|
|
@@ -578,9 +574,6 @@ module Parse
|
|
578
574
|
def relation_changes?
|
579
575
|
changed.any? { |key| relations[key.to_sym] }
|
580
576
|
end
|
581
|
-
|
582
577
|
end # HasMany
|
583
578
|
end #Associations
|
584
|
-
|
585
|
-
|
586
579
|
end # Parse
|
@@ -1,10 +1,10 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
|
-
require_relative
|
5
|
-
require_relative
|
6
|
-
require_relative
|
7
|
-
require_relative
|
4
|
+
require_relative "../pointer"
|
5
|
+
require_relative "collection_proxy"
|
6
|
+
require_relative "pointer_collection_proxy"
|
7
|
+
require_relative "relation_collection_proxy"
|
8
8
|
|
9
9
|
module Parse
|
10
10
|
module Associations
|
@@ -115,8 +115,7 @@ module Parse
|
|
115
115
|
|
116
116
|
# has one are not property but instance scope methods
|
117
117
|
def has_one(key, scope = nil, **opts)
|
118
|
-
|
119
|
-
opts.reverse_merge!({as: key, field: parse_class.columnize, scope_only: false})
|
118
|
+
opts.reverse_merge!({ as: key, field: parse_class.columnize, scope_only: false })
|
120
119
|
klassName = opts[:as].to_parse_class
|
121
120
|
foreign_field = opts[:field].to_sym
|
122
121
|
ivar = :"@_has_one_#{key}"
|
@@ -140,7 +139,7 @@ module Parse
|
|
140
139
|
query.instance_exec(&scope)
|
141
140
|
query.conditions(*args) if args.present?
|
142
141
|
else
|
143
|
-
query.instance_exec(*args
|
142
|
+
query.instance_exec(*args, &scope)
|
144
143
|
end
|
145
144
|
instance = nil # help clean up ruby gc
|
146
145
|
elsif args.present?
|
@@ -152,12 +151,8 @@ module Parse
|
|
152
151
|
return query.first if block.nil?
|
153
152
|
block.call(query.first)
|
154
153
|
end
|
155
|
-
|
156
154
|
end
|
157
|
-
|
158
155
|
end
|
159
|
-
|
160
156
|
end
|
161
|
-
|
162
157
|
end
|
163
158
|
end
|
@@ -1,12 +1,11 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
|
-
require
|
5
|
-
require
|
6
|
-
require
|
7
|
-
require
|
8
|
-
require_relative
|
9
|
-
|
4
|
+
require "active_model"
|
5
|
+
require "active_support"
|
6
|
+
require "active_support/inflector"
|
7
|
+
require "active_support/core_ext/object"
|
8
|
+
require_relative "collection_proxy"
|
10
9
|
|
11
10
|
module Parse
|
12
11
|
# A PointerCollectionProxy is a collection proxy that only allows Parse Pointers (Objects)
|
@@ -101,7 +100,5 @@ module Parse
|
|
101
100
|
def as_json(opts = nil)
|
102
101
|
parse_pointers.as_json(opts)
|
103
102
|
end
|
104
|
-
|
105
103
|
end
|
106
|
-
|
107
104
|
end
|
@@ -1,10 +1,10 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
|
-
require
|
5
|
-
require
|
6
|
-
require
|
7
|
-
require_relative
|
4
|
+
require "active_support"
|
5
|
+
require "active_support/inflector"
|
6
|
+
require "active_support/core_ext/object"
|
7
|
+
require_relative "pointer_collection_proxy"
|
8
8
|
|
9
9
|
module Parse
|
10
10
|
# The RelationCollectionProxy is similar to a PointerCollectionProxy except that
|
@@ -36,7 +36,6 @@ module Parse
|
|
36
36
|
# clearing out the change information for the collection if saved successfully.
|
37
37
|
# @see PointerCollectionProxy
|
38
38
|
class RelationCollectionProxy < PointerCollectionProxy
|
39
|
-
|
40
39
|
define_attribute_methods :additions, :removals
|
41
40
|
# @!attribute [r] removals
|
42
41
|
# The objects that have been newly removed to this collection
|
@@ -55,7 +54,7 @@ module Parse
|
|
55
54
|
# You can get items within the collection relation filtered by a specific set
|
56
55
|
# of query constraints.
|
57
56
|
def all(constraints = {})
|
58
|
-
q = query(
|
57
|
+
q = query({ limit: :max }.merge(constraints))
|
59
58
|
if block_given?
|
60
59
|
# if we have a query, then use the Proc with it (more efficient)
|
61
60
|
return q.present? ? q.results(&Proc.new) : collection.each(&Proc.new)
|
@@ -69,7 +68,6 @@ module Parse
|
|
69
68
|
q = forward :"#{@key}_relation_query"
|
70
69
|
end
|
71
70
|
|
72
|
-
|
73
71
|
# Add Parse::Objects to the relation.
|
74
72
|
# @overload add(parse_object)
|
75
73
|
# Add a Parse::Object or Parse::Pointer to this relation.
|
@@ -157,7 +155,5 @@ module Parse
|
|
157
155
|
list.each { |d| add(d) }
|
158
156
|
@collection
|
159
157
|
end
|
160
|
-
|
161
158
|
end
|
162
|
-
|
163
159
|
end
|
data/lib/parse/model/bytes.rb
CHANGED
@@ -1,24 +1,24 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
|
-
require
|
5
|
-
require
|
4
|
+
require "active_support"
|
5
|
+
require "active_support/core_ext/object"
|
6
6
|
require_relative "model"
|
7
|
-
require
|
8
|
-
|
7
|
+
require "base64"
|
9
8
|
|
10
9
|
module Parse
|
11
10
|
|
12
11
|
# Support for the Bytes type in Parse
|
13
12
|
class Bytes < Model
|
14
13
|
# The default attributes in a Parse Bytes hash.
|
15
|
-
ATTRIBUTES = {__type: :string, base64: :string }.freeze
|
14
|
+
ATTRIBUTES = { __type: :string, base64: :string }.freeze
|
16
15
|
# @return [String] the base64 string representing the content
|
17
16
|
attr_accessor :base64
|
18
17
|
# @return [TYPE_BYTES]
|
19
|
-
def self.parse_class; TYPE_BYTES; end
|
18
|
+
def self.parse_class; TYPE_BYTES; end
|
20
19
|
# @return [TYPE_BYTES]
|
21
|
-
def parse_class; self.class.parse_class; end
|
20
|
+
def parse_class; self.class.parse_class; end
|
21
|
+
|
22
22
|
alias_method :__type, :parse_class
|
23
23
|
|
24
24
|
# initialize with a base64 string or a Bytes object
|
@@ -47,7 +47,7 @@ module Parse
|
|
47
47
|
|
48
48
|
def attributes=(a)
|
49
49
|
if a.is_a?(String)
|
50
|
-
|
50
|
+
@bytes = a
|
51
51
|
elsif a.is_a?(Hash)
|
52
52
|
@bytes = a["base64"] || @bytes
|
53
53
|
end
|
@@ -58,7 +58,5 @@ module Parse
|
|
58
58
|
return false unless u.is_a?(self.class)
|
59
59
|
@base64 == u.base64
|
60
60
|
end
|
61
|
-
|
62
61
|
end
|
63
|
-
|
64
62
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
# frozen_string_literal: true
|
3
|
-
require_relative
|
3
|
+
require_relative "../object"
|
4
4
|
|
5
5
|
module Parse
|
6
6
|
# This class represents the data and columns contained in the standard Parse
|
@@ -36,7 +36,6 @@ module Parse
|
|
36
36
|
# @see Push
|
37
37
|
# @see Parse::Object
|
38
38
|
class Installation < Parse::Object
|
39
|
-
|
40
39
|
parse_class Parse::Model::CLASS_INSTALLATION
|
41
40
|
# @!attribute gcm_sender_id
|
42
41
|
# This field only has meaning for Android installations that use the GCM
|
@@ -126,7 +125,6 @@ module Parse
|
|
126
125
|
# This is implemented as a has_one association to the Session class using the {installation_id}.
|
127
126
|
# @version 1.7.1
|
128
127
|
# @return [Parse::Session] The associated {Parse::Session} that might be tied to this installation
|
129
|
-
has_one :session, ->{ where(installation_id: i.installation_id) }, scope_only: true
|
128
|
+
has_one :session, -> { where(installation_id: i.installation_id) }, scope_only: true
|
130
129
|
end
|
131
|
-
|
132
130
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
# frozen_string_literal: true
|
3
|
-
require_relative
|
4
|
-
require_relative
|
3
|
+
require_relative "../object"
|
4
|
+
require_relative "user"
|
5
5
|
|
6
6
|
module Parse
|
7
7
|
# This class represents the data and columns contained in the standard Parse `_Product` collection.
|
@@ -22,7 +22,6 @@ module Parse
|
|
22
22
|
# end
|
23
23
|
# @see Parse::Object
|
24
24
|
class Product < Parse::Object
|
25
|
-
|
26
25
|
parse_class Parse::Model::CLASS_PRODUCT
|
27
26
|
# @!attribute download
|
28
27
|
# @return [String] the file payload for this product download.
|
@@ -56,7 +55,5 @@ module Parse
|
|
56
55
|
# The title for this product. This field is required by Parse.
|
57
56
|
# @return [String] the title for this product.
|
58
57
|
property :title, required: true
|
59
|
-
|
60
58
|
end
|
61
|
-
|
62
59
|
end
|
@@ -1,7 +1,8 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
# frozen_string_literal: true
|
3
|
-
require_relative
|
4
|
-
require_relative
|
3
|
+
require_relative "../object"
|
4
|
+
require_relative "user"
|
5
|
+
|
5
6
|
module Parse
|
6
7
|
# This class represents the data and columns contained in the standard Parse `_Role` collection.
|
7
8
|
# Roles allow the an application to group a set of {Parse::User} records with the same set of
|
@@ -23,7 +24,6 @@ module Parse
|
|
23
24
|
# end
|
24
25
|
# @see Parse::Object
|
25
26
|
class Role < Parse::Object
|
26
|
-
|
27
27
|
parse_class Parse::Model::CLASS_ROLE
|
28
28
|
# @!attribute name
|
29
29
|
# @return [String] the name of this role.
|
@@ -37,7 +37,5 @@ module Parse
|
|
37
37
|
# This attribute is mapped as a `has_many` Parse relation association with the {Parse::User} class.
|
38
38
|
# @return [RelationCollectionProxy<User>] a Parse relation of users belonging to this role.
|
39
39
|
has_many :users, through: :relation
|
40
|
-
|
41
40
|
end
|
42
|
-
|
43
41
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
# frozen_string_literal: true
|
3
|
-
require_relative
|
3
|
+
require_relative "../object"
|
4
4
|
|
5
5
|
module Parse
|
6
6
|
# This class represents the data and columns contained in the standard Parse
|
@@ -28,7 +28,6 @@ module Parse
|
|
28
28
|
#
|
29
29
|
# @see Parse::Object
|
30
30
|
class Session < Parse::Object
|
31
|
-
|
32
31
|
parse_class Parse::Model::CLASS_SESSION
|
33
32
|
|
34
33
|
# @!attribute created_with
|
@@ -63,7 +62,7 @@ module Parse
|
|
63
62
|
# in the {Parse::Installation} collection. This is implemented as a has_one scope.
|
64
63
|
# @version 1.7.1
|
65
64
|
# @return [Parse::Installation] The associated {Parse::Installation} tied to this session
|
66
|
-
has_one :installation, ->{ where(installation_id: i.installation_id) }, scope_only: true
|
65
|
+
has_one :installation, -> { where(installation_id: i.installation_id) }, scope_only: true
|
67
66
|
|
68
67
|
# Return the Session record for this session token.
|
69
68
|
# @param token [String] the session token
|
@@ -75,7 +74,5 @@ module Parse
|
|
75
74
|
end
|
76
75
|
nil
|
77
76
|
end
|
78
|
-
|
79
77
|
end
|
80
|
-
|
81
78
|
end
|
@@ -1,23 +1,30 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
|
-
require_relative
|
4
|
+
require_relative "../object"
|
5
|
+
|
5
6
|
module Parse
|
6
7
|
class Error
|
7
8
|
# 200 Error code indicating that the username is missing or empty.
|
8
|
-
class UsernameMissingError < Error; end
|
9
|
+
class UsernameMissingError < Error; end
|
10
|
+
|
9
11
|
# 201 Error code indicating that the password is missing or empty.
|
10
|
-
class PasswordMissingError < Error; end
|
12
|
+
class PasswordMissingError < Error; end
|
13
|
+
|
11
14
|
# Error code 202: indicating that the username has already been taken.
|
12
|
-
class UsernameTakenError < Error; end
|
15
|
+
class UsernameTakenError < Error; end
|
16
|
+
|
13
17
|
# 203 Error code indicating that the email has already been taken.
|
14
|
-
class EmailTakenError < Error; end
|
18
|
+
class EmailTakenError < Error; end
|
19
|
+
|
15
20
|
# 204 Error code indicating that the email is missing, but must be specified.
|
16
|
-
class EmailMissing < Error; end
|
21
|
+
class EmailMissing < Error; end
|
22
|
+
|
17
23
|
# 205 Error code indicating that a user with the specified email was not found.
|
18
|
-
class EmailNotFound < Error; end
|
24
|
+
class EmailNotFound < Error; end
|
25
|
+
|
19
26
|
# 125 Error code indicating that the email address was invalid.
|
20
|
-
class InvalidEmailAddress < Error; end
|
27
|
+
class InvalidEmailAddress < Error; end
|
21
28
|
end
|
22
29
|
|
23
30
|
# The main class representing the _User table in Parse. A user can either be signed up or anonymous.
|
@@ -137,7 +144,6 @@ module Parse
|
|
137
144
|
#
|
138
145
|
# @see Parse::Object
|
139
146
|
class User < Parse::Object
|
140
|
-
|
141
147
|
parse_class Parse::Model::CLASS_USER
|
142
148
|
# @return [String] The session token if this user is logged in.
|
143
149
|
attr_accessor :session_token
|
@@ -189,7 +195,7 @@ module Parse
|
|
189
195
|
# @see #anonymous?
|
190
196
|
# @return [String] The anonymous identifier for this anonymous user.
|
191
197
|
def anonymous_id
|
192
|
-
auth_data[
|
198
|
+
auth_data["anonymous"]["id"] if auth_data.present? && auth_data["anonymous"].is_a?(Hash)
|
193
199
|
end
|
194
200
|
|
195
201
|
# Adds the third-party authentication data to for a given service.
|
@@ -212,12 +218,12 @@ module Parse
|
|
212
218
|
apply_attributes!(response.result)
|
213
219
|
end
|
214
220
|
|
215
|
-
|
216
221
|
# @!visibility private
|
217
222
|
# So that apply_attributes! works with session_token for login
|
218
223
|
def session_token_set_attribute!(token, track = false)
|
219
224
|
@session_token = token.to_s
|
220
225
|
end
|
226
|
+
|
221
227
|
alias_method :sessionToken_set_attribute!, :session_token_set_attribute!
|
222
228
|
|
223
229
|
# @return [Boolean] true if this user has a session token.
|
@@ -341,7 +347,7 @@ module Parse
|
|
341
347
|
when Parse::Response::ERROR_EMAIL_TAKEN
|
342
348
|
raise Parse::Error::EmailTakenError, response
|
343
349
|
end
|
344
|
-
raise
|
350
|
+
raise Parse::Client::ResponseError, response
|
345
351
|
end
|
346
352
|
|
347
353
|
# Automatically and implicitly signup a user if it did not already exists and
|
@@ -353,7 +359,7 @@ module Parse
|
|
353
359
|
# @return [User] a logged in user, or nil.
|
354
360
|
# @see User.create
|
355
361
|
def self.autologin_service(service_name, auth_data, body: {})
|
356
|
-
body = body.merge({authData: {service_name => auth_data} })
|
362
|
+
body = body.merge({ authData: { service_name => auth_data } })
|
357
363
|
self.create(body)
|
358
364
|
end
|
359
365
|
|
@@ -364,7 +370,7 @@ module Parse
|
|
364
370
|
# This method will raise all the exceptions from the similar `create` method.
|
365
371
|
# @see User.create
|
366
372
|
def self.signup(username, password, email = nil, body: {})
|
367
|
-
body = body.merge({username: username, password: password })
|
373
|
+
body = body.merge({ username: username, password: password })
|
368
374
|
body[:email] = email if email.present?
|
369
375
|
self.create(body)
|
370
376
|
end
|
@@ -427,7 +433,5 @@ module Parse
|
|
427
433
|
end
|
428
434
|
@session_token
|
429
435
|
end
|
430
|
-
|
431
436
|
end
|
432
|
-
|
433
437
|
end
|