braze_api_client 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (64) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile +9 -0
  3. data/LICENSE.md +9 -0
  4. data/README.md +191 -0
  5. data/Rakefile +10 -0
  6. data/braze_api_client.gemspec +38 -0
  7. data/docs/Attributes.md +58 -0
  8. data/docs/AttributesArray.md +18 -0
  9. data/docs/AttributesCurrentLocation.md +20 -0
  10. data/docs/AttributesFacebook.md +22 -0
  11. data/docs/AttributesPushTokens.md +22 -0
  12. data/docs/AttributesTwitter.md +26 -0
  13. data/docs/Event.md +26 -0
  14. data/docs/EventsArray.md +18 -0
  15. data/docs/GeneralError.md +20 -0
  16. data/docs/Identifier.md +51 -0
  17. data/docs/IdentifierOneOf.md +18 -0
  18. data/docs/IdentifierOneOf1.md +18 -0
  19. data/docs/IdentifierOneOf2.md +18 -0
  20. data/docs/RestApi.md +427 -0
  21. data/docs/UsersTrackRequest.md +18 -0
  22. data/docs/UsersTrackResponse.md +24 -0
  23. data/git_push.sh +16 -0
  24. data/lib/braze_api_client/api/rest_api.rb +400 -0
  25. data/lib/braze_api_client/api_client.rb +390 -0
  26. data/lib/braze_api_client/api_error.rb +57 -0
  27. data/lib/braze_api_client/configuration.rb +294 -0
  28. data/lib/braze_api_client/models/attributes.rb +458 -0
  29. data/lib/braze_api_client/models/attributes_array.rb +225 -0
  30. data/lib/braze_api_client/models/attributes_current_location.rb +227 -0
  31. data/lib/braze_api_client/models/attributes_facebook.rb +238 -0
  32. data/lib/braze_api_client/models/attributes_push_tokens.rb +246 -0
  33. data/lib/braze_api_client/models/attributes_twitter.rb +254 -0
  34. data/lib/braze_api_client/models/event.rb +264 -0
  35. data/lib/braze_api_client/models/events_array.rb +220 -0
  36. data/lib/braze_api_client/models/general_error.rb +227 -0
  37. data/lib/braze_api_client/models/identifier.rb +106 -0
  38. data/lib/braze_api_client/models/identifier_one_of.rb +223 -0
  39. data/lib/braze_api_client/models/identifier_one_of1.rb +223 -0
  40. data/lib/braze_api_client/models/identifier_one_of2.rb +223 -0
  41. data/lib/braze_api_client/models/users_track_request.rb +245 -0
  42. data/lib/braze_api_client/models/users_track_response.rb +245 -0
  43. data/lib/braze_api_client/version.rb +15 -0
  44. data/lib/braze_api_client.rb +55 -0
  45. data/spec/api/rest_api_spec.rb +101 -0
  46. data/spec/api_client_spec.rb +226 -0
  47. data/spec/configuration_spec.rb +42 -0
  48. data/spec/models/attributes_array_spec.rb +34 -0
  49. data/spec/models/attributes_current_location_spec.rb +40 -0
  50. data/spec/models/attributes_facebook_spec.rb +46 -0
  51. data/spec/models/attributes_push_tokens_spec.rb +46 -0
  52. data/spec/models/attributes_spec.rb +166 -0
  53. data/spec/models/attributes_twitter_spec.rb +58 -0
  54. data/spec/models/event_spec.rb +58 -0
  55. data/spec/models/events_array_spec.rb +34 -0
  56. data/spec/models/general_error_spec.rb +40 -0
  57. data/spec/models/identifier_one_of1_spec.rb +34 -0
  58. data/spec/models/identifier_one_of2_spec.rb +34 -0
  59. data/spec/models/identifier_one_of_spec.rb +34 -0
  60. data/spec/models/identifier_spec.rb +31 -0
  61. data/spec/models/users_track_request_spec.rb +34 -0
  62. data/spec/models/users_track_response_spec.rb +52 -0
  63. data/spec/spec_helper.rb +111 -0
  64. metadata +164 -0
@@ -0,0 +1,220 @@
1
+ =begin
2
+ #Braze
3
+
4
+ #Track users, send messages, export data, and more
5
+
6
+ The version of the OpenAPI document: 0.1.0
7
+
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 5.2.1
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module BrazeClient
17
+ class EventsArray
18
+ attr_accessor :attributes
19
+
20
+ # Attribute mapping from ruby-style variable name to JSON key.
21
+ def self.attribute_map
22
+ {
23
+ :'attributes' => :'attributes'
24
+ }
25
+ end
26
+
27
+ # Returns all the JSON keys this model knows about
28
+ def self.acceptable_attributes
29
+ attribute_map.values
30
+ end
31
+
32
+ # Attribute type mapping.
33
+ def self.openapi_types
34
+ {
35
+ :'attributes' => :'Array<Event>'
36
+ }
37
+ end
38
+
39
+ # List of attributes with nullable: true
40
+ def self.openapi_nullable
41
+ Set.new([
42
+ ])
43
+ end
44
+
45
+ # Initializes the object
46
+ # @param [Hash] attributes Model attributes in the form of hash
47
+ def initialize(attributes = {})
48
+ if (!attributes.is_a?(Hash))
49
+ fail ArgumentError, "The input argument (attributes) must be a hash in `BrazeClient::EventsArray` initialize method"
50
+ end
51
+
52
+ # check to see if the attribute exists and convert string to symbol for hash key
53
+ attributes = attributes.each_with_object({}) { |(k, v), h|
54
+ if (!self.class.attribute_map.key?(k.to_sym))
55
+ fail ArgumentError, "`#{k}` is not a valid attribute in `BrazeClient::EventsArray`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
56
+ end
57
+ h[k.to_sym] = v
58
+ }
59
+
60
+ if attributes.key?(:'attributes')
61
+ if (value = attributes[:'attributes']).is_a?(Array)
62
+ self.attributes = value
63
+ end
64
+ end
65
+ end
66
+
67
+ # Show invalid properties with the reasons. Usually used together with valid?
68
+ # @return Array for valid properties with the reasons
69
+ def list_invalid_properties
70
+ invalid_properties = Array.new
71
+ invalid_properties
72
+ end
73
+
74
+ # Check to see if the all the properties in the model are valid
75
+ # @return true if the model is valid
76
+ def valid?
77
+ true
78
+ end
79
+
80
+ # Checks equality by comparing each attribute.
81
+ # @param [Object] Object to be compared
82
+ def ==(o)
83
+ return true if self.equal?(o)
84
+ self.class == o.class &&
85
+ attributes == o.attributes
86
+ end
87
+
88
+ # @see the `==` method
89
+ # @param [Object] Object to be compared
90
+ def eql?(o)
91
+ self == o
92
+ end
93
+
94
+ # Calculates hash code according to all attributes.
95
+ # @return [Integer] Hash code
96
+ def hash
97
+ [attributes].hash
98
+ end
99
+
100
+ # Builds the object from hash
101
+ # @param [Hash] attributes Model attributes in the form of hash
102
+ # @return [Object] Returns the model itself
103
+ def self.build_from_hash(attributes)
104
+ new.build_from_hash(attributes)
105
+ end
106
+
107
+ # Builds the object from hash
108
+ # @param [Hash] attributes Model attributes in the form of hash
109
+ # @return [Object] Returns the model itself
110
+ def build_from_hash(attributes)
111
+ return nil unless attributes.is_a?(Hash)
112
+ self.class.openapi_types.each_pair do |key, type|
113
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
114
+ self.send("#{key}=", nil)
115
+ elsif type =~ /\AArray<(.*)>/i
116
+ # check to ensure the input is an array given that the attribute
117
+ # is documented as an array but the input is not
118
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
119
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
120
+ end
121
+ elsif !attributes[self.class.attribute_map[key]].nil?
122
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
123
+ end
124
+ end
125
+
126
+ self
127
+ end
128
+
129
+ # Deserializes the data based on type
130
+ # @param string type Data type
131
+ # @param string value Value to be deserialized
132
+ # @return [Object] Deserialized data
133
+ def _deserialize(type, value)
134
+ case type.to_sym
135
+ when :Time
136
+ Time.parse(value)
137
+ when :Date
138
+ Date.parse(value)
139
+ when :String
140
+ value.to_s
141
+ when :Integer
142
+ value.to_i
143
+ when :Float
144
+ value.to_f
145
+ when :Boolean
146
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
147
+ true
148
+ else
149
+ false
150
+ end
151
+ when :Object
152
+ # generic object (usually a Hash), return directly
153
+ value
154
+ when /\AArray<(?<inner_type>.+)>\z/
155
+ inner_type = Regexp.last_match[:inner_type]
156
+ value.map { |v| _deserialize(inner_type, v) }
157
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
158
+ k_type = Regexp.last_match[:k_type]
159
+ v_type = Regexp.last_match[:v_type]
160
+ {}.tap do |hash|
161
+ value.each do |k, v|
162
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
163
+ end
164
+ end
165
+ else # model
166
+ # models (e.g. Pet) or oneOf
167
+ klass = BrazeClient.const_get(type)
168
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
169
+ end
170
+ end
171
+
172
+ # Returns the string representation of the object
173
+ # @return [String] String presentation of the object
174
+ def to_s
175
+ to_hash.to_s
176
+ end
177
+
178
+ # to_body is an alias to to_hash (backward compatibility)
179
+ # @return [Hash] Returns the object in the form of hash
180
+ def to_body
181
+ to_hash
182
+ end
183
+
184
+ # Returns the object in the form of hash
185
+ # @return [Hash] Returns the object in the form of hash
186
+ def to_hash
187
+ hash = {}
188
+ self.class.attribute_map.each_pair do |attr, param|
189
+ value = self.send(attr)
190
+ if value.nil?
191
+ is_nullable = self.class.openapi_nullable.include?(attr)
192
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
193
+ end
194
+
195
+ hash[param] = _to_hash(value)
196
+ end
197
+ hash
198
+ end
199
+
200
+ # Outputs non-array value in the form of hash
201
+ # For object, use to_hash. Otherwise, just return the value
202
+ # @param [Object] value Any valid value
203
+ # @return [Hash] Returns the value in the form of hash
204
+ def _to_hash(value)
205
+ if value.is_a?(Array)
206
+ value.compact.map { |v| _to_hash(v) }
207
+ elsif value.is_a?(Hash)
208
+ {}.tap do |hash|
209
+ value.each { |k, v| hash[k] = _to_hash(v) }
210
+ end
211
+ elsif value.respond_to? :to_hash
212
+ value.to_hash
213
+ else
214
+ value
215
+ end
216
+ end
217
+
218
+ end
219
+
220
+ end
@@ -0,0 +1,227 @@
1
+ =begin
2
+ #Braze
3
+
4
+ #Track users, send messages, export data, and more
5
+
6
+ The version of the OpenAPI document: 0.1.0
7
+
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 5.2.1
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module BrazeClient
17
+ class GeneralError
18
+ attr_accessor :code
19
+
20
+ attr_accessor :message
21
+
22
+ # Attribute mapping from ruby-style variable name to JSON key.
23
+ def self.attribute_map
24
+ {
25
+ :'code' => :'code',
26
+ :'message' => :'message'
27
+ }
28
+ end
29
+
30
+ # Returns all the JSON keys this model knows about
31
+ def self.acceptable_attributes
32
+ attribute_map.values
33
+ end
34
+
35
+ # Attribute type mapping.
36
+ def self.openapi_types
37
+ {
38
+ :'code' => :'Integer',
39
+ :'message' => :'String'
40
+ }
41
+ end
42
+
43
+ # List of attributes with nullable: true
44
+ def self.openapi_nullable
45
+ Set.new([
46
+ ])
47
+ end
48
+
49
+ # Initializes the object
50
+ # @param [Hash] attributes Model attributes in the form of hash
51
+ def initialize(attributes = {})
52
+ if (!attributes.is_a?(Hash))
53
+ fail ArgumentError, "The input argument (attributes) must be a hash in `BrazeClient::GeneralError` initialize method"
54
+ end
55
+
56
+ # check to see if the attribute exists and convert string to symbol for hash key
57
+ attributes = attributes.each_with_object({}) { |(k, v), h|
58
+ if (!self.class.attribute_map.key?(k.to_sym))
59
+ fail ArgumentError, "`#{k}` is not a valid attribute in `BrazeClient::GeneralError`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
60
+ end
61
+ h[k.to_sym] = v
62
+ }
63
+
64
+ if attributes.key?(:'code')
65
+ self.code = attributes[:'code']
66
+ end
67
+
68
+ if attributes.key?(:'message')
69
+ self.message = attributes[:'message']
70
+ end
71
+ end
72
+
73
+ # Show invalid properties with the reasons. Usually used together with valid?
74
+ # @return Array for valid properties with the reasons
75
+ def list_invalid_properties
76
+ invalid_properties = Array.new
77
+ invalid_properties
78
+ end
79
+
80
+ # Check to see if the all the properties in the model are valid
81
+ # @return true if the model is valid
82
+ def valid?
83
+ true
84
+ end
85
+
86
+ # Checks equality by comparing each attribute.
87
+ # @param [Object] Object to be compared
88
+ def ==(o)
89
+ return true if self.equal?(o)
90
+ self.class == o.class &&
91
+ code == o.code &&
92
+ message == o.message
93
+ end
94
+
95
+ # @see the `==` method
96
+ # @param [Object] Object to be compared
97
+ def eql?(o)
98
+ self == o
99
+ end
100
+
101
+ # Calculates hash code according to all attributes.
102
+ # @return [Integer] Hash code
103
+ def hash
104
+ [code, message].hash
105
+ end
106
+
107
+ # Builds the object from hash
108
+ # @param [Hash] attributes Model attributes in the form of hash
109
+ # @return [Object] Returns the model itself
110
+ def self.build_from_hash(attributes)
111
+ new.build_from_hash(attributes)
112
+ end
113
+
114
+ # Builds the object from hash
115
+ # @param [Hash] attributes Model attributes in the form of hash
116
+ # @return [Object] Returns the model itself
117
+ def build_from_hash(attributes)
118
+ return nil unless attributes.is_a?(Hash)
119
+ self.class.openapi_types.each_pair do |key, type|
120
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
121
+ self.send("#{key}=", nil)
122
+ elsif type =~ /\AArray<(.*)>/i
123
+ # check to ensure the input is an array given that the attribute
124
+ # is documented as an array but the input is not
125
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
126
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
127
+ end
128
+ elsif !attributes[self.class.attribute_map[key]].nil?
129
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
130
+ end
131
+ end
132
+
133
+ self
134
+ end
135
+
136
+ # Deserializes the data based on type
137
+ # @param string type Data type
138
+ # @param string value Value to be deserialized
139
+ # @return [Object] Deserialized data
140
+ def _deserialize(type, value)
141
+ case type.to_sym
142
+ when :Time
143
+ Time.parse(value)
144
+ when :Date
145
+ Date.parse(value)
146
+ when :String
147
+ value.to_s
148
+ when :Integer
149
+ value.to_i
150
+ when :Float
151
+ value.to_f
152
+ when :Boolean
153
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
154
+ true
155
+ else
156
+ false
157
+ end
158
+ when :Object
159
+ # generic object (usually a Hash), return directly
160
+ value
161
+ when /\AArray<(?<inner_type>.+)>\z/
162
+ inner_type = Regexp.last_match[:inner_type]
163
+ value.map { |v| _deserialize(inner_type, v) }
164
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
165
+ k_type = Regexp.last_match[:k_type]
166
+ v_type = Regexp.last_match[:v_type]
167
+ {}.tap do |hash|
168
+ value.each do |k, v|
169
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
170
+ end
171
+ end
172
+ else # model
173
+ # models (e.g. Pet) or oneOf
174
+ klass = BrazeClient.const_get(type)
175
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
176
+ end
177
+ end
178
+
179
+ # Returns the string representation of the object
180
+ # @return [String] String presentation of the object
181
+ def to_s
182
+ to_hash.to_s
183
+ end
184
+
185
+ # to_body is an alias to to_hash (backward compatibility)
186
+ # @return [Hash] Returns the object in the form of hash
187
+ def to_body
188
+ to_hash
189
+ end
190
+
191
+ # Returns the object in the form of hash
192
+ # @return [Hash] Returns the object in the form of hash
193
+ def to_hash
194
+ hash = {}
195
+ self.class.attribute_map.each_pair do |attr, param|
196
+ value = self.send(attr)
197
+ if value.nil?
198
+ is_nullable = self.class.openapi_nullable.include?(attr)
199
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
200
+ end
201
+
202
+ hash[param] = _to_hash(value)
203
+ end
204
+ hash
205
+ end
206
+
207
+ # Outputs non-array value in the form of hash
208
+ # For object, use to_hash. Otherwise, just return the value
209
+ # @param [Object] value Any valid value
210
+ # @return [Hash] Returns the value in the form of hash
211
+ def _to_hash(value)
212
+ if value.is_a?(Array)
213
+ value.compact.map { |v| _to_hash(v) }
214
+ elsif value.is_a?(Hash)
215
+ {}.tap do |hash|
216
+ value.each { |k, v| hash[k] = _to_hash(v) }
217
+ end
218
+ elsif value.respond_to? :to_hash
219
+ value.to_hash
220
+ else
221
+ value
222
+ end
223
+ end
224
+
225
+ end
226
+
227
+ end
@@ -0,0 +1,106 @@
1
+ =begin
2
+ #Braze
3
+
4
+ #Track users, send messages, export data, and more
5
+
6
+ The version of the OpenAPI document: 0.1.0
7
+
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 5.2.1
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module BrazeClient
17
+ module Identifier
18
+ class << self
19
+ # List of class defined in oneOf (OpenAPI v3)
20
+ def openapi_one_of
21
+ [
22
+ :'IdentifierOneOf',
23
+ :'IdentifierOneOf1',
24
+ :'IdentifierOneOf2'
25
+ ]
26
+ end
27
+
28
+ # Builds the object
29
+ # @param [Mixed] Data to be matched against the list of oneOf items
30
+ # @return [Object] Returns the model or the data itself
31
+ def build(data)
32
+ # Go through the list of oneOf items and attempt to identify the appropriate one.
33
+ # Note:
34
+ # - We do not attempt to check whether exactly one item matches.
35
+ # - No advanced validation of types in some cases (e.g. "x: { type: string }" will happily match { x: 123 })
36
+ # due to the way the deserialization is made in the base_object template (it just casts without verifying).
37
+ # - TODO: scalar values are defacto behaving as if they were nullable.
38
+ # - TODO: logging when debugging is set.
39
+ openapi_one_of.each do |klass|
40
+ begin
41
+ next if klass == :AnyType # "nullable: true"
42
+ typed_data = find_and_cast_into_type(klass, data)
43
+ return typed_data if typed_data
44
+ rescue # rescue all errors so we keep iterating even if the current item lookup raises
45
+ end
46
+ end
47
+
48
+ openapi_one_of.include?(:AnyType) ? data : nil
49
+ end
50
+
51
+ private
52
+
53
+ SchemaMismatchError = Class.new(StandardError)
54
+
55
+ # Note: 'File' is missing here because in the regular case we get the data _after_ a call to JSON.parse.
56
+ def find_and_cast_into_type(klass, data)
57
+ return if data.nil?
58
+
59
+ case klass.to_s
60
+ when 'Boolean'
61
+ return data if data.instance_of?(TrueClass) || data.instance_of?(FalseClass)
62
+ when 'Float'
63
+ return data if data.instance_of?(Float)
64
+ when 'Integer'
65
+ return data if data.instance_of?(Integer)
66
+ when 'Time'
67
+ return Time.parse(data)
68
+ when 'Date'
69
+ return Date.parse(data)
70
+ when 'String'
71
+ return data if data.instance_of?(String)
72
+ when 'Object' # "type: object"
73
+ return data if data.instance_of?(Hash)
74
+ when /\AArray<(?<sub_type>.+)>\z/ # "type: array"
75
+ if data.instance_of?(Array)
76
+ sub_type = Regexp.last_match[:sub_type]
77
+ return data.map { |item| find_and_cast_into_type(sub_type, item) }
78
+ end
79
+ when /\AHash<String, (?<sub_type>.+)>\z/ # "type: object" with "additionalProperties: { ... }"
80
+ if data.instance_of?(Hash) && data.keys.all? { |k| k.instance_of?(Symbol) || k.instance_of?(String) }
81
+ sub_type = Regexp.last_match[:sub_type]
82
+ return data.each_with_object({}) { |(k, v), hsh| hsh[k] = find_and_cast_into_type(sub_type, v) }
83
+ end
84
+ else # model
85
+ const = BrazeClient.const_get(klass)
86
+ if const
87
+ if const.respond_to?(:openapi_one_of) # nested oneOf model
88
+ model = const.build(data)
89
+ return model if model
90
+ else
91
+ # raise if data contains keys that are not known to the model
92
+ raise unless (data.keys - const.acceptable_attributes).empty?
93
+ model = const.build_from_hash(data)
94
+ return model if model && model.valid?
95
+ end
96
+ end
97
+ end
98
+
99
+ raise # if no match by now, raise
100
+ rescue
101
+ raise SchemaMismatchError, "#{data} doesn't match the #{klass} type"
102
+ end
103
+ end
104
+ end
105
+
106
+ end