parse-stack 1.5.1 → 1.5.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Changes.md +15 -1
- data/Gemfile.lock +10 -10
- data/README.md +23 -9
- data/bin/console +3 -0
- data/lib/parse/api/analytics.rb +1 -1
- data/lib/parse/api/objects.rb +1 -1
- data/lib/parse/api/users.rb +1 -1
- data/lib/parse/client.rb +77 -40
- data/lib/parse/client/caching.rb +9 -5
- data/lib/parse/client/protocol.rb +47 -0
- data/lib/parse/client/request.rb +66 -37
- data/lib/parse/client/response.rb +39 -21
- data/lib/parse/model/acl.rb +4 -9
- data/lib/parse/model/associations/belongs_to.rb +97 -9
- data/lib/parse/model/associations/collection_proxy.rb +89 -29
- data/lib/parse/model/associations/has_many.rb +301 -28
- data/lib/parse/model/associations/has_one.rb +98 -4
- data/lib/parse/model/associations/pointer_collection_proxy.rb +48 -16
- data/lib/parse/model/associations/relation_collection_proxy.rb +61 -36
- data/lib/parse/model/bytes.rb +11 -5
- data/lib/parse/model/classes/installation.rb +50 -3
- data/lib/parse/model/classes/role.rb +7 -2
- data/lib/parse/model/classes/session.rb +21 -4
- data/lib/parse/model/classes/user.rb +122 -22
- data/lib/parse/model/core/actions.rb +7 -3
- data/lib/parse/model/core/properties.rb +14 -13
- data/lib/parse/model/core/querying.rb +16 -10
- data/lib/parse/model/core/schema.rb +2 -3
- data/lib/parse/model/date.rb +18 -12
- data/lib/parse/model/file.rb +77 -19
- data/lib/parse/model/geopoint.rb +70 -12
- data/lib/parse/model/model.rb +84 -8
- data/lib/parse/model/object.rb +225 -94
- data/lib/parse/model/pointer.rb +94 -13
- data/lib/parse/model/push.rb +76 -4
- data/lib/parse/query.rb +356 -41
- data/lib/parse/query/constraints.rb +399 -29
- data/lib/parse/query/ordering.rb +21 -8
- data/lib/parse/stack.rb +1 -0
- data/lib/parse/stack/version.rb +2 -1
- data/lib/parse/webhooks.rb +0 -24
- data/lib/parse/webhooks/payload.rb +54 -1
- data/lib/parse/webhooks/registration.rb +13 -2
- metadata +2 -2
@@ -5,18 +5,112 @@ require_relative '../pointer'
|
|
5
5
|
require_relative 'collection_proxy'
|
6
6
|
require_relative 'pointer_collection_proxy'
|
7
7
|
require_relative 'relation_collection_proxy'
|
8
|
-
|
9
|
-
# name of the class/parse table that contains the foreign associated record.
|
10
|
-
# All belongs to relationship column types have the special data type of :pointer.
|
8
|
+
|
11
9
|
module Parse
|
12
10
|
module Associations
|
13
|
-
|
11
|
+
# The `has_one` creates a one-to-one association with another Parse class.
|
12
|
+
# This association says that the other class in the association contains a
|
13
|
+
# foreign pointer column which references instances of this class. If your
|
14
|
+
# model contains a column that is a Parse pointer to another class, you should
|
15
|
+
# use `belongs_to` for that association instead.
|
16
|
+
#
|
17
|
+
# Defining a `has_one` property generates a helper query method to fetch a
|
18
|
+
# particular record from a foreign class. This is useful for setting up the
|
19
|
+
# inverse relationship accessors of a `belongs_to`. In the case of the
|
20
|
+
# `has_one` relationship, the `:field` option represents the name of the
|
21
|
+
# column of the foreign class where the Parse pointer is stored. By default,
|
22
|
+
# the lower-first camel case version of the Parse class name is used.
|
23
|
+
#
|
24
|
+
# In the example below, a `Band` has a local column named `manager` which has
|
25
|
+
# a pointer to a `Parse::User` (_:user_) record. This setups up the accessor for `Band`
|
26
|
+
# objects to access the band's manager.
|
27
|
+
#
|
28
|
+
# Since we know there is a column named `manager` in the `Band` class that
|
29
|
+
# points to a single `Parse::User`, you can setup the inverse association
|
30
|
+
# read accessor in the `Parse::User` class. Note, that to change the
|
31
|
+
# association, you need to modify the `manager` property on the band instance
|
32
|
+
# since it contains the `belongs_to` property.
|
33
|
+
#
|
34
|
+
# # every band has a manager
|
35
|
+
# class Band < Parse::Object
|
36
|
+
# belongs_to :manager, as: :user
|
37
|
+
# end
|
38
|
+
#
|
39
|
+
# band = Band.first id: '12345'
|
40
|
+
# # the user represented by this manager
|
41
|
+
# user = band.manger
|
42
|
+
#
|
43
|
+
# # every user manages a band
|
44
|
+
# class Parse::User
|
45
|
+
# # inverse relationship to `Band.belongs_to :manager`
|
46
|
+
# has_one :band, field: :manager
|
47
|
+
# end
|
48
|
+
#
|
49
|
+
# user = Parse::User.first
|
50
|
+
#
|
51
|
+
# user.band # similar to performing: Band.first(:manager => user)
|
52
|
+
#
|
53
|
+
#
|
54
|
+
# You may optionally use `has_one` with scopes, in order to fine tune the
|
55
|
+
# query result. Using the example above, you can customize the query with
|
56
|
+
# a scope that only fetches the association if the band is approved. If
|
57
|
+
# the association cannot be fetched, `nil` is returned.
|
58
|
+
#
|
59
|
+
# # adding to previous example
|
60
|
+
# class Band < Parse::Object
|
61
|
+
# property :approved, :boolean
|
62
|
+
# property :approved_date, :date
|
63
|
+
# end
|
64
|
+
#
|
65
|
+
# # every user manages a band
|
66
|
+
# class Parse::User
|
67
|
+
# has_one :recently_approved, ->{ where(order: :approved_date.desc) }, field: :manager, as: :band
|
68
|
+
# has_one :band_by_status, ->(status) { where(approved: status) }, field: :manager, as: :band
|
69
|
+
# end
|
70
|
+
#
|
71
|
+
# # gets the band most recently approved
|
72
|
+
# user.recently_approved
|
73
|
+
# # equivalent: Band.first(manager: user, order: :approved_date.desc)
|
74
|
+
#
|
75
|
+
# # fetch the managed band that is not approved
|
76
|
+
# user.band_by_status(false)
|
77
|
+
# # equivalent: Band.first(manager: user, approved: false)
|
78
|
+
#
|
79
|
+
# @see Parse::Associations::BelongsTo
|
80
|
+
# @see Parse::Associations::HasMany
|
14
81
|
module HasOne
|
15
82
|
|
83
|
+
# @!method self.has_one(key, scope = nil, opts = {})
|
84
|
+
# Creates a one-to-one association with another Parse model.
|
85
|
+
# @param [Symbol] key The singularized version of the foreign class and the name of the
|
86
|
+
# *foreign* column in the foreign Parse table where the pointer is stored.
|
87
|
+
# @param [Proc] scope A proc that can customize the query by applying
|
88
|
+
# additional constraints when fetching the associated record. Works similarly as
|
89
|
+
# ActiveModel associations described in section {http://api.rubyonrails.org/classes/ActiveRecord/Associations/ClassMethods.html Customizing the Query}
|
90
|
+
# @option opts [Symbol] :field override the name of the remote column
|
91
|
+
# where the pointer is stored. By default this is inferred as
|
92
|
+
# the columnized of the key parameter.
|
93
|
+
# @option opts [Symbol] :as override the inferred Parse::Object subclass.
|
94
|
+
# By default this is inferred as the singularized camel case version of
|
95
|
+
# the key parameter. This option allows you to override the Parse model used
|
96
|
+
# to perform the query for the association, while allowing you to have a
|
97
|
+
# different accessor name.
|
98
|
+
# @option opts [Boolean] scope_only Setting this option to `true`,
|
99
|
+
# makes the association fetch based only on the scope provided and does
|
100
|
+
# not use the local instance object as a foreign pointer in the query.
|
101
|
+
# This allows for cases where another property of the local class, is
|
102
|
+
# needed to match the resulting records in the association.
|
103
|
+
# @see String#columnize
|
104
|
+
# @see Associations::HasMany.has_many
|
105
|
+
# @return [Parse::Object] a Parse::Object subclass when using the accessor
|
106
|
+
# when fetching the association.
|
107
|
+
|
108
|
+
# @!visibility private
|
16
109
|
def self.included(base)
|
17
110
|
base.extend(ClassMethods)
|
18
111
|
end
|
19
112
|
|
113
|
+
# @!visibility private
|
20
114
|
module ClassMethods
|
21
115
|
|
22
116
|
# has one are not property but instance scope methods
|
@@ -7,21 +7,31 @@ require 'active_support/inflector'
|
|
7
7
|
require 'active_support/core_ext/object'
|
8
8
|
require_relative 'collection_proxy'
|
9
9
|
|
10
|
-
# A PointerCollectionProxy is a collection proxy that only allows Parse Pointers (Objects)
|
11
|
-
# to be part of the collection. This is done by typecasting the collection to a particular
|
12
|
-
# Parse class. Ex. An Artist may have several Song objects. Therefore an Artist could have a
|
13
|
-
# column :songs, that is an array (collection) of Song (Parse::Object) objects.
|
14
|
-
# Because this collection is typecasted, we can do some more interesting things.
|
15
|
-
module Parse
|
16
10
|
|
11
|
+
module Parse
|
12
|
+
# A PointerCollectionProxy is a collection proxy that only allows Parse Pointers (Objects)
|
13
|
+
# to be part of the collection. This is done by typecasting the collection to a particular
|
14
|
+
# Parse class. Ex. An Artist may have several Song objects. Therefore an Artist could have a
|
15
|
+
# column :songs, that is an array (collection) of Song (Parse::Object subclass) objects.
|
17
16
|
class PointerCollectionProxy < CollectionProxy
|
18
17
|
|
18
|
+
# @!attribute [rw] collection
|
19
|
+
# The internal backing store of the collection.
|
20
|
+
# @return [Array<Parse::Object>]
|
21
|
+
# @see CollectionProxy#collection
|
19
22
|
def collection=(c)
|
20
23
|
notify_will_change!
|
21
24
|
@collection = c
|
22
25
|
end
|
23
|
-
|
24
|
-
#
|
26
|
+
|
27
|
+
# Add Parse::Objects to the collection.
|
28
|
+
# @overload add(parse_object)
|
29
|
+
# Add a Parse::Object or Parse::Pointer to this collection.
|
30
|
+
# @param parse_object [Parse::Object,Parse::Pointer] the object to add
|
31
|
+
# @overload add(parse_objects)
|
32
|
+
# Add an array of Parse::Objects or Parse::Pointers to this collection.
|
33
|
+
# @param parse_objects [Array<Parse::Object,Parse::Pointer>] the array to append.
|
34
|
+
# @return [Array<Parse::Object>] the collection
|
25
35
|
def add(*items)
|
26
36
|
notify_will_change! if items.count > 0
|
27
37
|
items.flatten.parse_objects.each do |item|
|
@@ -30,7 +40,14 @@ module Parse
|
|
30
40
|
@collection
|
31
41
|
end
|
32
42
|
|
33
|
-
#
|
43
|
+
# Removes Parse::Objects from the collection.
|
44
|
+
# @overload remove(parse_object)
|
45
|
+
# Remove a Parse::Object or Parse::Pointer to this collection.
|
46
|
+
# @param parse_object [Parse::Object,Parse::Pointer] the object to remove
|
47
|
+
# @overload remove(parse_objects)
|
48
|
+
# Remove an array of Parse::Objects or Parse::Pointers from this collection.
|
49
|
+
# @param parse_objects [Array<Parse::Object,Parse::Pointer>] the array of objects to remove.
|
50
|
+
# @return [Array<Parse::Object>] the collection
|
34
51
|
def remove(*items)
|
35
52
|
notify_will_change! if items.count > 0
|
36
53
|
items.flatten.parse_objects.each do |item|
|
@@ -39,36 +56,51 @@ module Parse
|
|
39
56
|
@collection
|
40
57
|
end
|
41
58
|
|
59
|
+
# Atomically add a set of Parse::Objects to this collection.
|
60
|
+
# This is done by making the API request directly with Parse server; the
|
61
|
+
# local object is not updated with changes.
|
62
|
+
# @see CollectionProxy#add!
|
63
|
+
# @see #add_unique!
|
42
64
|
def add!(*items)
|
43
65
|
super(items.flatten.parse_pointers)
|
44
66
|
end
|
45
67
|
|
68
|
+
# Atomically add a set of Parse::Objects to this collection for those not already
|
69
|
+
# in the collection.
|
70
|
+
# This is done by making the API request directly with Parse server; the
|
71
|
+
# local object is not updated with changes.
|
72
|
+
# @see CollectionProxy#add_unique!
|
73
|
+
# @see #add!
|
46
74
|
def add_unique!(*items)
|
47
75
|
super(items.flatten.parse_pointers)
|
48
76
|
end
|
49
77
|
|
78
|
+
# Atomically remove a set of Parse::Objects to this collection.
|
79
|
+
# This is done by making the API request directly with Parse server; the
|
80
|
+
# local object is not updated with changes.
|
81
|
+
# @see CollectionProxy#remove!
|
50
82
|
def remove!(*items)
|
51
83
|
super(items.flatten.parse_pointers)
|
52
84
|
end
|
53
85
|
|
54
|
-
#
|
55
|
-
#
|
56
|
-
# in the array that is of pointer state (object with unfetch data) and fetch
|
57
|
-
# them in parallel.
|
58
|
-
|
86
|
+
# Force fetch the set of pointer objects in this collection.
|
87
|
+
# @see Array.fetch_objects!
|
59
88
|
def fetch!
|
60
89
|
collection.fetch_objects!
|
61
90
|
end
|
62
91
|
|
92
|
+
# Fetch the set of pointer objects in this collection.
|
93
|
+
# @see Array.fetch_objects
|
63
94
|
def fetch
|
64
95
|
collection.fetch_objects
|
65
96
|
end
|
66
|
-
|
67
|
-
#
|
97
|
+
|
98
|
+
# Encode the collection as a JSON object of Parse::Pointers.
|
68
99
|
def as_json(*args)
|
69
100
|
collection.parse_pointers.as_json
|
70
101
|
end
|
71
102
|
|
103
|
+
# @return [Array<Parse::Pointer>] an array of pointers representing this collection.
|
72
104
|
def parse_pointers
|
73
105
|
collection.parse_pointers
|
74
106
|
end
|
@@ -6,39 +6,44 @@ require 'active_support/inflector'
|
|
6
6
|
require 'active_support/core_ext/object'
|
7
7
|
require_relative 'pointer_collection_proxy'
|
8
8
|
|
9
|
-
# The RelationCollectionProxy is similar to a PointerCollectionProxy except that
|
10
|
-
# there is no actual "array" object in Parse. Parse treats relation through an
|
11
|
-
# intermediary table (a.k.a. join table). Whenever a developer wants the
|
12
|
-
# contents of a collection, the foreign table needs to be queried instead.
|
13
|
-
# In this scenario, the parse_class: initializer argument should be passed in order to
|
14
|
-
# know which remote table needs to be queried in order to fetch the items of the collection.
|
15
|
-
#
|
16
|
-
# Unlike managing an array of Pointers, relations in Parse are done throug atomic operations,
|
17
|
-
# which have a specific API. The design of this proxy is to maintain two sets of lists,
|
18
|
-
# items to be added to the relation and a separate list of items to be removed from the
|
19
|
-
# relation.
|
20
|
-
#
|
21
|
-
# Because this relationship is based on queryable Parse table, we are also able to
|
22
|
-
# not just get all the items in a collection, but also provide additional constraints to
|
23
|
-
# get matching items within the relation collection.
|
24
|
-
#
|
25
|
-
# When creating a Relation proxy, all the delegate methods defined in the superclasses
|
26
|
-
# need to be implemented, in addition to a few others with the key parameter:
|
27
|
-
# _relation_query and _commit_relation_updates . :'key'_relation_query should return a
|
28
|
-
# Parse::Query object that is properly tied to the foreign table class related to this object column.
|
29
|
-
# Example, if an Artist has many Song objects, then the query to be returned by this method
|
30
|
-
# should be a Parse::Query for the class 'Song'.
|
31
|
-
# Because relation changes are separate from object changes, you can call save on a
|
32
|
-
# relation collection to save the current add and remove operations. Because the delegate needs
|
33
|
-
# to be informed of the changes being committed, it will be notified
|
34
|
-
# through :'key'_commit_relation_updates message. The delegate is also in charge of
|
35
|
-
# clearing out the change information for the collection if saved successfully.
|
36
|
-
|
37
9
|
module Parse
|
38
|
-
|
10
|
+
# The RelationCollectionProxy is similar to a PointerCollectionProxy except that
|
11
|
+
# there is no actual "array" object in Parse. Parse treats relation through an
|
12
|
+
# intermediary table (a.k.a. join table). Whenever a developer wants the
|
13
|
+
# contents of a collection, the foreign table needs to be queried instead.
|
14
|
+
# In this scenario, the parse_class: initializer argument should be passed in order to
|
15
|
+
# know which remote table needs to be queried in order to fetch the items of the collection.
|
16
|
+
#
|
17
|
+
# Unlike managing an array of Pointers, relations in Parse are done throug atomic operations,
|
18
|
+
# which have a specific API. The design of this proxy is to maintain two sets of lists,
|
19
|
+
# items to be added to the relation and a separate list of items to be removed from the
|
20
|
+
# relation.
|
21
|
+
#
|
22
|
+
# Because this relationship is based on queryable Parse table, we are also able to
|
23
|
+
# not just get all the items in a collection, but also provide additional constraints to
|
24
|
+
# get matching items within the relation collection.
|
25
|
+
#
|
26
|
+
# When creating a Relation proxy, all the delegate methods defined in the superclasses
|
27
|
+
# need to be implemented, in addition to a few others with the key parameter:
|
28
|
+
# _relation_query and _commit_relation_updates . :'key'_relation_query should return a
|
29
|
+
# Parse::Query object that is properly tied to the foreign table class related to this object column.
|
30
|
+
# Example, if an Artist has many Song objects, then the query to be returned by this method
|
31
|
+
# should be a Parse::Query for the class 'Song'.
|
32
|
+
# Because relation changes are separate from object changes, you can call save on a
|
33
|
+
# relation collection to save the current add and remove operations. Because the delegate needs
|
34
|
+
# to be informed of the changes being committed, it will be notified
|
35
|
+
# through :'key'_commit_relation_updates message. The delegate is also in charge of
|
36
|
+
# clearing out the change information for the collection if saved successfully.
|
37
|
+
# @see PointerCollectionProxy
|
39
38
|
class RelationCollectionProxy < PointerCollectionProxy
|
40
39
|
|
41
40
|
define_attribute_methods :additions, :removals
|
41
|
+
# @!attribute [r] removals
|
42
|
+
# The objects that have been newly removed to this collection
|
43
|
+
# @return [Array<Parse::Object>]
|
44
|
+
# @!attribute [r] additions
|
45
|
+
# The objects that have been newly added to this collection
|
46
|
+
# @return [Array<Parse::Object>]
|
42
47
|
attr_reader :additions, :removals
|
43
48
|
|
44
49
|
def initialize(collection = nil, delegate: nil, key: nil, parse_class: nil)
|
@@ -65,9 +70,14 @@ module Parse
|
|
65
70
|
end
|
66
71
|
|
67
72
|
|
68
|
-
#
|
69
|
-
#
|
70
|
-
#
|
73
|
+
# Add Parse::Objects to the relation.
|
74
|
+
# @overload add(parse_object)
|
75
|
+
# Add a Parse::Object or Parse::Pointer to this relation.
|
76
|
+
# @param parse_object [Parse::Object,Parse::Pointer] the object to add
|
77
|
+
# @overload add(parse_objects)
|
78
|
+
# Add an array of Parse::Objects or Parse::Pointers to this relation.
|
79
|
+
# @param parse_objects [Array<Parse::Object,Parse::Pointer>] the array to append.
|
80
|
+
# @return [Array<Parse::Object>] the collection
|
71
81
|
def add(*items)
|
72
82
|
items = items.flatten.parse_objects
|
73
83
|
return @collection if items.empty?
|
@@ -85,9 +95,14 @@ module Parse
|
|
85
95
|
@collection
|
86
96
|
end
|
87
97
|
|
88
|
-
#
|
89
|
-
#
|
90
|
-
#
|
98
|
+
# Removes Parse::Objects from the relation.
|
99
|
+
# @overload remove(parse_object)
|
100
|
+
# Remove a Parse::Object or Parse::Pointer to this relation.
|
101
|
+
# @param parse_object [Parse::Object,Parse::Pointer] the object to remove
|
102
|
+
# @overload remove(parse_objects)
|
103
|
+
# Remove an array of Parse::Objects or Parse::Pointers from this relation.
|
104
|
+
# @param parse_objects [Array<Parse::Object,Parse::Pointer>] the array of objects to remove.
|
105
|
+
# @return [Array<Parse::Object>] the collection
|
91
106
|
def remove(*items)
|
92
107
|
items = items.flatten.parse_objects
|
93
108
|
return @collection if items.empty?
|
@@ -103,31 +118,41 @@ module Parse
|
|
103
118
|
@collection
|
104
119
|
end
|
105
120
|
|
121
|
+
# Atomically add a set of Parse::Objects to this relation.
|
122
|
+
# This is done by making the API request directly with Parse server; the
|
123
|
+
# local object is not updated with changes.
|
106
124
|
def add!(*items)
|
107
125
|
return false unless @delegate.respond_to?(:op_add_relation!)
|
108
126
|
items = items.flatten.parse_pointers
|
109
127
|
@delegate.send :op_add_relation!, @key, items
|
110
128
|
end
|
111
129
|
|
130
|
+
# Atomically add a set of Parse::Objects to this relation.
|
131
|
+
# This is done by making the API request directly with Parse server; the
|
132
|
+
# local object is not updated with changes.
|
112
133
|
def add_unique!(*items)
|
113
134
|
return false unless @delegate.respond_to?(:op_add_relation!)
|
114
135
|
items = items.flatten.parse_pointers
|
115
136
|
@delegate.send :op_add_relation!, @key, items
|
116
137
|
end
|
117
138
|
|
139
|
+
# Atomically remove a set of Parse::Objects to this relation.
|
140
|
+
# This is done by making the API request directly with Parse server; the
|
141
|
+
# local object is not updated with changes.
|
118
142
|
def remove!(*items)
|
119
143
|
return false unless @delegate.respond_to?(:op_remove_relation!)
|
120
144
|
items = items.flatten.parse_pointers
|
121
145
|
@delegate.send :op_remove_relation!, @key, items
|
122
146
|
end
|
123
147
|
|
124
|
-
#
|
148
|
+
# Save the changes to the relation
|
125
149
|
def save
|
126
150
|
unless @removals.empty? && @additions.empty?
|
127
151
|
forward :"#{@key}_commit_relation_updates"
|
128
152
|
end
|
129
153
|
end
|
130
154
|
|
155
|
+
# @see #add
|
131
156
|
def <<(*list)
|
132
157
|
list.each { |d| add(d) }
|
133
158
|
@collection
|
data/lib/parse/model/bytes.rb
CHANGED
@@ -6,31 +6,37 @@ require 'active_support/core_ext/object'
|
|
6
6
|
require_relative "model"
|
7
7
|
require 'base64'
|
8
8
|
|
9
|
-
|
9
|
+
|
10
10
|
module Parse
|
11
11
|
|
12
|
+
# Support for the Bytes type in Parse
|
12
13
|
class Bytes < Model
|
13
14
|
ATTRIBUTES = {__type: :string, base64: :string }.freeze
|
15
|
+
# @return [String] the base64 string representing the content
|
14
16
|
attr_accessor :base64
|
15
|
-
|
17
|
+
# @return [TYPE_BYTES]
|
18
|
+
def self.parse_class; TYPE_BYTES; end;
|
19
|
+
# @return [TYPE_BYTES]
|
16
20
|
def parse_class; self.class.parse_class; end;
|
17
21
|
alias_method :__type, :parse_class
|
18
22
|
|
19
23
|
# initialize with a base64 string or a Bytes object
|
24
|
+
# @param bytes [String] The content as base64 string.
|
20
25
|
def initialize(bytes = "")
|
21
26
|
@base64 = (bytes.is_a?(Bytes) ? bytes.base64 : bytes).dup
|
22
27
|
end
|
23
28
|
|
29
|
+
# @return [Hash]
|
24
30
|
def attributes
|
25
31
|
ATTRIBUTES
|
26
32
|
end
|
27
33
|
|
28
|
-
#
|
34
|
+
# Base64 encode and set the instance contents
|
29
35
|
def encode(s)
|
30
36
|
@base64 = Base64.encode64(s)
|
31
37
|
end
|
32
38
|
|
33
|
-
#
|
39
|
+
# Get the content as decoded base64 bytes
|
34
40
|
def decoded
|
35
41
|
Base64.decode64(@base64 || "")
|
36
42
|
end
|
@@ -43,7 +49,7 @@ module Parse
|
|
43
49
|
end
|
44
50
|
end
|
45
51
|
|
46
|
-
#
|
52
|
+
# Two Parse::Bytes objects are equal if they have the same base64 signature
|
47
53
|
def ==(u)
|
48
54
|
return false unless u.is_a?(self.class)
|
49
55
|
@base64 == u.base64
|
@@ -3,23 +3,70 @@
|
|
3
3
|
require_relative '../object'
|
4
4
|
|
5
5
|
module Parse
|
6
|
-
|
6
|
+
# This class represents the data and columns contained in the standard Parse
|
7
|
+
# `_Installation` collection. This class is also responsible for managing the
|
8
|
+
# device tokens for mobile devices in order to use push notifications. All queries done
|
9
|
+
# to send pushes using Parse::Push are performed against the Installation collection.
|
10
|
+
# An installation object represents an instance of your app being installed
|
11
|
+
# on a device. These objects are used to store subscription data for
|
12
|
+
# installations which have subscribed to one or more push notification channels.
|
13
|
+
# @see Push
|
7
14
|
class Installation < Parse::Object
|
8
|
-
parse_class Parse::Model::CLASS_INSTALLATION
|
9
15
|
|
16
|
+
parse_class Parse::Model::CLASS_INSTALLATION
|
17
|
+
# This field only has meaning for Android installations that use the GCM
|
18
|
+
# push type. It is reserved for directing Parse to send pushes to this
|
19
|
+
# installation with an alternate GCM sender ID. This field should generally
|
20
|
+
# not be set unless you are uploading installation data from another push
|
21
|
+
# provider. If you set this field, then you must set the GCM API key
|
22
|
+
# corresponding to this GCM sender ID in your Parse application’s push settings.
|
23
|
+
# @return [String]
|
10
24
|
property :gcm_sender_id, :string, field: :GCMSenderId
|
25
|
+
# A unique identifier for this installation’s client application. In iOS, this is the Bundle Identifier.
|
26
|
+
# @return [String]
|
11
27
|
property :app_identifier
|
28
|
+
# The display name of the client application to which this installation belongs.
|
29
|
+
# @return [String]
|
12
30
|
property :app_name
|
31
|
+
# The version string of the client application to which this installation belongs.
|
32
|
+
# @return [String]
|
13
33
|
property :app_version
|
34
|
+
# A number field representing the last known application badge for iOS installations.
|
35
|
+
# @return [Integer]
|
14
36
|
property :badge, :integer
|
37
|
+
# An array of the channels to which a device is currently subscribed.
|
38
|
+
# Note that **channelUris** (the Microsoft-generated push URIs for Windows devices) is
|
39
|
+
# not supported at this time.
|
40
|
+
# @return [Array]
|
15
41
|
property :channels, :array
|
42
|
+
# The Apple or Google generated token used to deliver messages to the APNs
|
43
|
+
# or GCM push networks respectively.
|
44
|
+
# @return [String]
|
16
45
|
property :device_token
|
46
|
+
# @return [Integer]
|
17
47
|
property :device_token_last_modified, :integer
|
18
|
-
|
48
|
+
# The type of device, “ios”, “android”, “winrt”, “winphone”, or “dotnet” (readonly).
|
49
|
+
# This property is implemented as a Parse::Stack enumeration.
|
50
|
+
# @return [String]
|
51
|
+
property :device_type, enum: [:ios, :android, :winrt, :winphone, :dotnet]
|
52
|
+
# Universally Unique Identifier (UUID) for the device used by Parse. It
|
53
|
+
# must be unique across all of an app’s installations. (readonly).
|
54
|
+
# @return [String]
|
19
55
|
property :installation_id
|
56
|
+
# The locale for this device.
|
57
|
+
# @return [String]
|
20
58
|
property :locale_identifier
|
59
|
+
# The version of the Parse SDK which this installation uses.
|
60
|
+
# @return [String]
|
21
61
|
property :parse_version
|
62
|
+
# This field is reserved for directing Parse to the push delivery network
|
63
|
+
# to be used. If the device is registered to receive pushes via GCM, this
|
64
|
+
# field will be marked “gcm”. If this device is not using GCM, and is
|
65
|
+
# using Parse’s push notification service, it will be blank (readonly).
|
66
|
+
# @return [String]
|
22
67
|
property :push_type
|
68
|
+
# The current time zone where the target device is located. This should be an IANA time zone identifier.
|
69
|
+
# @return [String]
|
23
70
|
property :time_zone
|
24
71
|
|
25
72
|
end
|