simplyq 0.8.0rc
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.rspec +3 -0
- data/.rubocop.yml +58 -0
- data/.rubocop_todo.yml +156 -0
- data/.tool-versions +1 -0
- data/CHANGELOG.md +5 -0
- data/CODE_OF_CONDUCT.md +84 -0
- data/Gemfile +27 -0
- data/LICENSE.txt +21 -0
- data/README.md +37 -0
- data/Rakefile +12 -0
- data/lib/simplyq/api/application_api.rb +82 -0
- data/lib/simplyq/api/endpoint_api.rb +178 -0
- data/lib/simplyq/api/event_api.rb +140 -0
- data/lib/simplyq/client.rb +304 -0
- data/lib/simplyq/configuration.rb +185 -0
- data/lib/simplyq/errors.rb +96 -0
- data/lib/simplyq/models/application.rb +196 -0
- data/lib/simplyq/models/delivery_attempt.rb +110 -0
- data/lib/simplyq/models/endpoint.rb +226 -0
- data/lib/simplyq/models/event.rb +133 -0
- data/lib/simplyq/models/inbound_event.rb +37 -0
- data/lib/simplyq/models/list.rb +120 -0
- data/lib/simplyq/version.rb +5 -0
- data/lib/simplyq/webhook.rb +102 -0
- data/lib/simplyq.rb +26 -0
- data/sig/simplyq.rbs +4 -0
- data/simplyq.gemspec +40 -0
- metadata +121 -0
@@ -0,0 +1,96 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Simplyq
|
4
|
+
class SimplyqError < StandardError
|
5
|
+
# @return [SimplyqResponse] response object that conveys basic information
|
6
|
+
# about the response that triggered the error
|
7
|
+
attr_accessor :response
|
8
|
+
|
9
|
+
attr_reader :message
|
10
|
+
attr_reader :code
|
11
|
+
attr_reader :error
|
12
|
+
attr_reader :http_status
|
13
|
+
attr_reader :http_headers
|
14
|
+
attr_reader :http_body
|
15
|
+
attr_reader :json_body
|
16
|
+
attr_reader :request_id
|
17
|
+
|
18
|
+
def initialize(message = nil, http_status: nil, http_body: nil,
|
19
|
+
http_headers: nil, code: nil, error: nil)
|
20
|
+
@message = message
|
21
|
+
@http_status = http_status
|
22
|
+
@http_body = http_body
|
23
|
+
@json_body = parse_body
|
24
|
+
@http_headers = http_headers || {}
|
25
|
+
@code = code
|
26
|
+
@request_id = @http_headers["request-id"]
|
27
|
+
@error = error
|
28
|
+
end
|
29
|
+
|
30
|
+
def parse_body
|
31
|
+
return if @http_body.nil?
|
32
|
+
|
33
|
+
@json_body = JSON.parse(@http_body, symbolize_names: true)
|
34
|
+
rescue JSON::ParserError
|
35
|
+
@json_body = nil
|
36
|
+
end
|
37
|
+
|
38
|
+
def to_s
|
39
|
+
status_string = @http_status.nil? ? "" : "(Status #{@http_status}) "
|
40
|
+
id_string = @request_id.nil? ? "" : "(Request #{@request_id}) "
|
41
|
+
"#{status_string}#{id_string}#{@message}"
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
# AuthenticationError is raised when invalid credentials are used to connect
|
46
|
+
# to SimplyQ's servers.
|
47
|
+
class AuthenticationError < SimplyqError
|
48
|
+
end
|
49
|
+
|
50
|
+
# APIConnectionError is raised in the event that the SDK can't connect to
|
51
|
+
# SimplyQ's servers. Reasons vary from a network split to bad TLS certs.
|
52
|
+
class APIConnectionError < SimplyqError
|
53
|
+
end
|
54
|
+
|
55
|
+
# APIError is a general error, that can be raised when other errors are not
|
56
|
+
# appropriate. It can also be used to raise new errors that have been added
|
57
|
+
# to the API but not yet added to the SDK or not in the current version.
|
58
|
+
class APIError < SimplyqError
|
59
|
+
end
|
60
|
+
|
61
|
+
# InvalidRequestError is raised when a request data is found to be invalid.
|
62
|
+
class InvalidRequestError < SimplyqError
|
63
|
+
attr_accessor :param
|
64
|
+
attr_accessor :errors
|
65
|
+
|
66
|
+
def initialize(message, param, http_status: nil, http_body: nil,
|
67
|
+
http_headers: nil, code: nil, error: nil, errors: [])
|
68
|
+
super(message, http_status: http_status, http_body: http_body,
|
69
|
+
http_headers: http_headers,
|
70
|
+
code: code)
|
71
|
+
@param = param
|
72
|
+
@errors = errors
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
# PaymentRequiredError is raised when your ccount is in bad standing or
|
77
|
+
# exceeded the quota limits on the free plan.
|
78
|
+
# Please go to your account's billing page or reach out to support.
|
79
|
+
class PaymentRequiredError < SimplyqError
|
80
|
+
end
|
81
|
+
|
82
|
+
# RateLimitError is raised when your account is putting too much pressure on
|
83
|
+
# SimplyQ's server. Please back off on request rate, or reach out to support.
|
84
|
+
class RateLimitError < SimplyqError
|
85
|
+
end
|
86
|
+
|
87
|
+
# PermissionError is raised when your account does not have the right
|
88
|
+
# permissions to perform an action.
|
89
|
+
class PermissionError < SimplyqError
|
90
|
+
end
|
91
|
+
|
92
|
+
# SignatureVerificationError is raised when the signature verification for a
|
93
|
+
# webhook fails
|
94
|
+
class SignatureVerificationError < SimplyqError
|
95
|
+
end
|
96
|
+
end
|
@@ -0,0 +1,196 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Simplyq
|
4
|
+
module Model
|
5
|
+
class Application
|
6
|
+
# Unique identifier for the application
|
7
|
+
attr_accessor :uid
|
8
|
+
|
9
|
+
attr_accessor :name
|
10
|
+
|
11
|
+
attr_accessor :rate_limit
|
12
|
+
|
13
|
+
attr_accessor :created_at
|
14
|
+
|
15
|
+
attr_accessor :updated_at
|
16
|
+
|
17
|
+
attr_accessor :retry_strategy
|
18
|
+
|
19
|
+
def initialize(attributes = {})
|
20
|
+
self.uid = attributes[:uid].to_s if attributes.key?(:uid)
|
21
|
+
|
22
|
+
self.name = attributes[:name] if attributes.key?(:name)
|
23
|
+
|
24
|
+
self.rate_limit = attributes[:rate_limit] if attributes.key?(:rate_limit)
|
25
|
+
|
26
|
+
self.created_at = attributes[:created_at] if attributes.key?(:created_at)
|
27
|
+
|
28
|
+
self.updated_at = attributes[:updated_at] if attributes.key?(:updated_at)
|
29
|
+
|
30
|
+
self.retry_strategy = if attributes.key?(:retry_strategy)
|
31
|
+
RetryStrategy.from_hash(attributes[:retry_strategy])
|
32
|
+
else
|
33
|
+
RetryStrategy.new
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
# The model identifier attribute used in list operations
|
38
|
+
#
|
39
|
+
# @return [Symbol]
|
40
|
+
def self.identifier
|
41
|
+
:uid
|
42
|
+
end
|
43
|
+
|
44
|
+
# Serializes the object from a hash
|
45
|
+
#
|
46
|
+
# @param hash [Hash] Hash with the object data
|
47
|
+
# @return [Simplyq::Model::Application]
|
48
|
+
def self.from_hash(hash)
|
49
|
+
return if hash.nil?
|
50
|
+
|
51
|
+
new(hash)
|
52
|
+
end
|
53
|
+
|
54
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
55
|
+
# @return Array for valid properties with the reasons
|
56
|
+
def validation_errors
|
57
|
+
invalid_properties = []
|
58
|
+
invalid_properties.push('invalid value for "uid", uid cannot be nil.') if @uid.nil?
|
59
|
+
|
60
|
+
if @uid.to_s.length > 255
|
61
|
+
invalid_properties.push('invalid value for "uid", the character length must be smaller than or equal to 255.')
|
62
|
+
end
|
63
|
+
|
64
|
+
if @uid.to_s.empty?
|
65
|
+
invalid_properties.push('invalid value for "uid", the character length must be great than or equal to 1.')
|
66
|
+
end
|
67
|
+
|
68
|
+
pattern = Regexp.new(/^[a-zA-Z0-9\-_.]+$/)
|
69
|
+
invalid_properties.push("invalid value for \"uid\", must conform to the pattern #{pattern}.") if @uid !~ pattern
|
70
|
+
|
71
|
+
invalid_properties.push('invalid value for "name", name cannot be nil.') if @name.nil?
|
72
|
+
|
73
|
+
unless @retry_strategy.valid?
|
74
|
+
invalid_properties.concat(@retry_strategy.validation_errors.map { |x| "retry_strategy.#{x}" })
|
75
|
+
end
|
76
|
+
|
77
|
+
invalid_properties
|
78
|
+
end
|
79
|
+
|
80
|
+
# Check to see if all the properties in the model are valid
|
81
|
+
def valid?
|
82
|
+
validation_errors.empty? && retry_strategy.valid?
|
83
|
+
end
|
84
|
+
|
85
|
+
def [](key)
|
86
|
+
instance_variable_get(:"@#{key}")
|
87
|
+
end
|
88
|
+
|
89
|
+
def ==(other)
|
90
|
+
return false unless other.is_a?(Application)
|
91
|
+
|
92
|
+
uid == other.uid &&
|
93
|
+
name == other.name &&
|
94
|
+
rate_limit == other.rate_limit &&
|
95
|
+
created_at == other.created_at &&
|
96
|
+
updated_at == other.updated_at &&
|
97
|
+
retry_strategy == other.retry_strategy
|
98
|
+
end
|
99
|
+
|
100
|
+
def to_h
|
101
|
+
{
|
102
|
+
uid: uid,
|
103
|
+
name: name,
|
104
|
+
rate_limit: rate_limit,
|
105
|
+
retry_strategy: retry_strategy.to_h,
|
106
|
+
created_at: created_at,
|
107
|
+
updated_at: updated_at
|
108
|
+
}
|
109
|
+
end
|
110
|
+
|
111
|
+
def to_json(*args)
|
112
|
+
to_h.to_json(*args)
|
113
|
+
end
|
114
|
+
|
115
|
+
class RetryStrategy
|
116
|
+
# The retry strategy type identifies what algorithm will be used
|
117
|
+
|
118
|
+
SUPPORTED_TYPES = [
|
119
|
+
DEFAULT_TYPE = "base_exponential_backoff_with_deadline",
|
120
|
+
"exponential_backoff",
|
121
|
+
"exponential_backoff_with_deadline",
|
122
|
+
"fixed_wait",
|
123
|
+
"fixed_wait_with_deadline"
|
124
|
+
].freeze
|
125
|
+
|
126
|
+
attr_accessor :type
|
127
|
+
|
128
|
+
attr_accessor :max_retries
|
129
|
+
|
130
|
+
attr_accessor :retry_delay
|
131
|
+
|
132
|
+
attr_accessor :deadline
|
133
|
+
|
134
|
+
def initialize(attributes = {})
|
135
|
+
self.type = DEFAULT_TYPE
|
136
|
+
self.type = attributes[:type] if attributes.key?(:type)
|
137
|
+
|
138
|
+
self.max_retries = attributes[:max_retries] if attributes.key?(:max_retries)
|
139
|
+
|
140
|
+
self.retry_delay = attributes[:retry_delay] if attributes.key?(:retry_delay)
|
141
|
+
|
142
|
+
self.deadline = attributes[:deadline] if attributes.key?(:deadline)
|
143
|
+
end
|
144
|
+
|
145
|
+
def self.from_hash(hash)
|
146
|
+
return if hash.nil?
|
147
|
+
|
148
|
+
new(hash)
|
149
|
+
end
|
150
|
+
|
151
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
152
|
+
# @return Array for valid properties with the reasons
|
153
|
+
def validation_errors
|
154
|
+
invalid_properties = []
|
155
|
+
|
156
|
+
unless SUPPORTED_TYPES.include?(@type)
|
157
|
+
invalid_properties.push("invalid value for \"type\", must be one of #{SUPPORTED_TYPES.join(", ")}.")
|
158
|
+
end
|
159
|
+
|
160
|
+
invalid_properties
|
161
|
+
end
|
162
|
+
|
163
|
+
# Check to see if all the properties in the model are valid
|
164
|
+
def valid?
|
165
|
+
validation_errors.empty?
|
166
|
+
end
|
167
|
+
|
168
|
+
def [](key)
|
169
|
+
instance_variable_get(:"@#{key}")
|
170
|
+
end
|
171
|
+
|
172
|
+
def ==(other)
|
173
|
+
return false unless other.is_a?(RetryStrategy)
|
174
|
+
|
175
|
+
type == other.type &&
|
176
|
+
max_retries == other.max_retries &&
|
177
|
+
retry_delay == other.retry_delay &&
|
178
|
+
deadline == other.deadline
|
179
|
+
end
|
180
|
+
|
181
|
+
def to_h
|
182
|
+
{
|
183
|
+
type: type,
|
184
|
+
max_retries: max_retries,
|
185
|
+
retry_delay: retry_delay,
|
186
|
+
deadline: deadline
|
187
|
+
}
|
188
|
+
end
|
189
|
+
|
190
|
+
def to_json(*args)
|
191
|
+
to_h.to_json(*args)
|
192
|
+
end
|
193
|
+
end
|
194
|
+
end
|
195
|
+
end
|
196
|
+
end
|
@@ -0,0 +1,110 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Simplyq
|
4
|
+
module Model
|
5
|
+
class DeliveryAttempt
|
6
|
+
attr_accessor :id
|
7
|
+
|
8
|
+
attr_accessor :event_id
|
9
|
+
|
10
|
+
attr_accessor :endpoint_id
|
11
|
+
|
12
|
+
# The response of the endpoint when a delivery attempt was made or null if not yet attempted.
|
13
|
+
attr_accessor :response
|
14
|
+
|
15
|
+
# The response code of the endpoint when the event delivery was attempted.
|
16
|
+
attr_accessor :response_status_code
|
17
|
+
|
18
|
+
# The delivery status of the event to the endpoint
|
19
|
+
attr_accessor :status
|
20
|
+
|
21
|
+
# The tigger of the delivery attempt
|
22
|
+
attr_accessor :trigger_type
|
23
|
+
|
24
|
+
# This is the timestamp of when the delivery attempt was made to the endpoint. In case it has not yet been attempted and the status of the delivery attempt is **pending**, then the value of the timestamp will be **null**.
|
25
|
+
attr_accessor :attempted_at
|
26
|
+
|
27
|
+
def initialize(attributes = {})
|
28
|
+
self.id = attributes[:id] if attributes.key?(:id)
|
29
|
+
|
30
|
+
self.event_id = attributes[:event_id] if attributes.key?(:event_id)
|
31
|
+
|
32
|
+
self.endpoint_id = attributes[:endpoint_id] if attributes.key?(:endpoint_id)
|
33
|
+
|
34
|
+
self.response = attributes[:response] if attributes.key?(:response)
|
35
|
+
|
36
|
+
self.response_status_code = attributes[:response_status_code] if attributes.key?(:response_status_code)
|
37
|
+
|
38
|
+
self.status = attributes[:status] if attributes.key?(:status)
|
39
|
+
|
40
|
+
self.trigger_type = attributes[:trigger_type] if attributes.key?(:trigger_type)
|
41
|
+
|
42
|
+
self.attempted_at = attributes[:attempted_at] if attributes.key?(:attempted_at)
|
43
|
+
end
|
44
|
+
|
45
|
+
# The model identifier attribute used in list operations
|
46
|
+
#
|
47
|
+
# @return [Symbol]
|
48
|
+
def self.identifier
|
49
|
+
:id
|
50
|
+
end
|
51
|
+
|
52
|
+
# Serializes the object from a hash
|
53
|
+
#
|
54
|
+
# @param hash [Hash] Hash with the object data
|
55
|
+
# @return [Simplyq::Model::Endpoint]
|
56
|
+
def self.from_hash(hash)
|
57
|
+
return if hash.nil?
|
58
|
+
|
59
|
+
new(hash)
|
60
|
+
end
|
61
|
+
|
62
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
63
|
+
# @return Array for valid properties with the reasons
|
64
|
+
def validation_errors
|
65
|
+
[]
|
66
|
+
end
|
67
|
+
|
68
|
+
# Check if the model is valid
|
69
|
+
# @return true if valid, false otherwise
|
70
|
+
def valid?
|
71
|
+
validation_errors.empty?
|
72
|
+
end
|
73
|
+
|
74
|
+
def [](key)
|
75
|
+
instance_variable_get(:"@#{key}")
|
76
|
+
end
|
77
|
+
|
78
|
+
def ==(other)
|
79
|
+
return false if other.nil?
|
80
|
+
|
81
|
+
self.class == other.class &&
|
82
|
+
id == other.id &&
|
83
|
+
event_id == other.event_id &&
|
84
|
+
endpoint_id == other.endpoint_id &&
|
85
|
+
response == other.response &&
|
86
|
+
response_status_code == other.response_status_code &&
|
87
|
+
status == other.status &&
|
88
|
+
trigger_type == other.trigger_type &&
|
89
|
+
attempted_at == other.attempted_at
|
90
|
+
end
|
91
|
+
|
92
|
+
def to_h
|
93
|
+
{
|
94
|
+
id: id,
|
95
|
+
event_id: event_id,
|
96
|
+
endpoint_id: endpoint_id,
|
97
|
+
response: response,
|
98
|
+
response_status_code: response_status_code,
|
99
|
+
status: status,
|
100
|
+
trigger_type: trigger_type,
|
101
|
+
attempted_at: attempted_at
|
102
|
+
}
|
103
|
+
end
|
104
|
+
|
105
|
+
def to_json(*args)
|
106
|
+
to_h.to_json(*args)
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|
@@ -0,0 +1,226 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Simplyq
|
4
|
+
module Model
|
5
|
+
class Endpoint
|
6
|
+
# Unique identifier of the endpoint inside the application.
|
7
|
+
attr_accessor :uid
|
8
|
+
|
9
|
+
attr_accessor :url
|
10
|
+
|
11
|
+
attr_accessor :version
|
12
|
+
|
13
|
+
attr_accessor :description
|
14
|
+
|
15
|
+
attr_accessor :filter_types
|
16
|
+
|
17
|
+
attr_accessor :topics
|
18
|
+
|
19
|
+
attr_accessor :active
|
20
|
+
|
21
|
+
attr_accessor :rate_limit
|
22
|
+
|
23
|
+
attr_accessor :headers
|
24
|
+
|
25
|
+
attr_accessor :secret
|
26
|
+
|
27
|
+
attr_accessor :created_at
|
28
|
+
|
29
|
+
attr_accessor :updated_at
|
30
|
+
|
31
|
+
def initialize(attributes = {})
|
32
|
+
self.uid = attributes[:uid] if attributes.key?(:uid)
|
33
|
+
|
34
|
+
self.url = attributes[:url] if attributes.key?(:url)
|
35
|
+
|
36
|
+
self.version = attributes[:version] if attributes.key?(:version)
|
37
|
+
|
38
|
+
self.description = attributes[:description] if attributes.key?(:description)
|
39
|
+
|
40
|
+
self.filter_types = attributes[:filter_types] if attributes.key?(:filter_types)
|
41
|
+
|
42
|
+
self.topics = attributes[:topics] if attributes.key?(:topics)
|
43
|
+
|
44
|
+
self.active = attributes[:active] if attributes.key?(:active)
|
45
|
+
|
46
|
+
self.rate_limit = attributes[:rate_limit] if attributes.key?(:rate_limit)
|
47
|
+
|
48
|
+
self.headers = if attributes.key?(:headers)
|
49
|
+
Headers.from_hash(attributes[:headers])
|
50
|
+
else
|
51
|
+
Headers.new
|
52
|
+
end
|
53
|
+
|
54
|
+
self.secret = attributes[:secret] if attributes.key?(:secret)
|
55
|
+
|
56
|
+
self.created_at = attributes[:created_at] if attributes.key?(:created_at)
|
57
|
+
|
58
|
+
self.updated_at = attributes[:updated_at] if attributes.key?(:updated_at)
|
59
|
+
end
|
60
|
+
|
61
|
+
# The model identifier attribute used in list operations
|
62
|
+
#
|
63
|
+
# @return [Symbol]
|
64
|
+
def self.identifier
|
65
|
+
:uid
|
66
|
+
end
|
67
|
+
|
68
|
+
# Serializes the object from a hash
|
69
|
+
#
|
70
|
+
# @param hash [Hash] Hash with the object data
|
71
|
+
# @return [Simplyq::Model::Endpoint]
|
72
|
+
def self.from_hash(hash)
|
73
|
+
return if hash.nil?
|
74
|
+
|
75
|
+
new(hash)
|
76
|
+
end
|
77
|
+
|
78
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
79
|
+
# @return Array for valid properties with the reasons
|
80
|
+
def validation_errors
|
81
|
+
invalid_properties = []
|
82
|
+
if !@uid.nil? && @uid.to_s.length > 255
|
83
|
+
invalid_properties.push('invalid value for "uid", the character length must be smaller than or equal to 255.')
|
84
|
+
end
|
85
|
+
|
86
|
+
if !@uid.nil? && @uid.to_s.empty?
|
87
|
+
invalid_properties.push('invalid value for "uid", the character length must be great than or equal to 1.')
|
88
|
+
end
|
89
|
+
|
90
|
+
pattern = Regexp.new(/^[a-zA-Z0-9\-_.]+$/)
|
91
|
+
if !@uid.nil? && @uid !~ pattern
|
92
|
+
invalid_properties.push("invalid value for \"uid\", must conform to the pattern #{pattern}.")
|
93
|
+
end
|
94
|
+
|
95
|
+
invalid_properties.push('invalid value for "url", url cannot be nil.') if @url.nil?
|
96
|
+
|
97
|
+
invalid_properties.push('invalid value for "version", version cannot be nil.') if @version.nil?
|
98
|
+
|
99
|
+
if !@topics.nil? && @topics.length > 5
|
100
|
+
invalid_properties.push('invalid value for "topics", number of items must be less than or equal to 5.')
|
101
|
+
end
|
102
|
+
|
103
|
+
if !@topics.nil? && @topics.empty?
|
104
|
+
invalid_properties.push('invalid value for "topics", number of items must be greater than or equal to 1.')
|
105
|
+
end
|
106
|
+
|
107
|
+
if !@rate_limit.nil? && @rate_limit < 1
|
108
|
+
invalid_properties.push('invalid value for "rate_limit", must be greater than or equal to 1.')
|
109
|
+
end
|
110
|
+
|
111
|
+
invalid_properties
|
112
|
+
end
|
113
|
+
|
114
|
+
# Check if the model is valid
|
115
|
+
# @return true if valid, false otherwise
|
116
|
+
def valid?
|
117
|
+
validation_errors.empty?
|
118
|
+
end
|
119
|
+
|
120
|
+
def [](key)
|
121
|
+
instance_variable_get(:"@#{key}")
|
122
|
+
end
|
123
|
+
|
124
|
+
def ==(other)
|
125
|
+
return false if other.nil?
|
126
|
+
|
127
|
+
self.class == other.class &&
|
128
|
+
uid == other.uid &&
|
129
|
+
url == other.url &&
|
130
|
+
version == other.version &&
|
131
|
+
description == other.description &&
|
132
|
+
filter_types == other.filter_types &&
|
133
|
+
topics == other.topics &&
|
134
|
+
active == other.active &&
|
135
|
+
rate_limit == other.rate_limit &&
|
136
|
+
headers == other.headers &&
|
137
|
+
secret == other.secret &&
|
138
|
+
created_at == other.created_at &&
|
139
|
+
updated_at == other.updated_at
|
140
|
+
end
|
141
|
+
|
142
|
+
def to_h
|
143
|
+
{
|
144
|
+
uid: uid,
|
145
|
+
url: url,
|
146
|
+
version: version,
|
147
|
+
description: description,
|
148
|
+
filter_types: filter_types,
|
149
|
+
topics: topics,
|
150
|
+
active: active,
|
151
|
+
rate_limit: rate_limit,
|
152
|
+
headers: headers.to_h,
|
153
|
+
secret: secret,
|
154
|
+
created_at: created_at,
|
155
|
+
updated_at: updated_at
|
156
|
+
}
|
157
|
+
end
|
158
|
+
|
159
|
+
def to_json(*args)
|
160
|
+
to_h.to_json(*args)
|
161
|
+
end
|
162
|
+
|
163
|
+
class Headers
|
164
|
+
attr_accessor :headers
|
165
|
+
|
166
|
+
attr_accessor :sensitive
|
167
|
+
|
168
|
+
def initialize(attributes = {})
|
169
|
+
self.headers = attributes[:headers] if attributes.key?(:headers)
|
170
|
+
|
171
|
+
self.sensitive = attributes[:sensitive] if attributes.key?(:sensitive)
|
172
|
+
end
|
173
|
+
|
174
|
+
def has_sensitive?
|
175
|
+
!sensitive.nil? && !sensitive.empty?
|
176
|
+
end
|
177
|
+
|
178
|
+
# Serializes the object from a hash
|
179
|
+
#
|
180
|
+
# @param hash [Hash] Hash with the object data
|
181
|
+
# @return [Simplyq::Model::Endpoint::Headers]
|
182
|
+
def self.from_hash(hash)
|
183
|
+
return if hash.nil?
|
184
|
+
|
185
|
+
new(hash)
|
186
|
+
end
|
187
|
+
|
188
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
189
|
+
#
|
190
|
+
# TODO: Add header object validation
|
191
|
+
#
|
192
|
+
# @return Array for valid properties with the reasons
|
193
|
+
def validation_errors
|
194
|
+
[]
|
195
|
+
end
|
196
|
+
|
197
|
+
def valid?
|
198
|
+
validation_errors.empty?
|
199
|
+
end
|
200
|
+
|
201
|
+
def [](key)
|
202
|
+
instance_variable_get(:"@#{key}")
|
203
|
+
end
|
204
|
+
|
205
|
+
def ==(other)
|
206
|
+
return false if other.nil?
|
207
|
+
|
208
|
+
self.class == other.class &&
|
209
|
+
headers == other.headers &&
|
210
|
+
sensitive == other.sensitive
|
211
|
+
end
|
212
|
+
|
213
|
+
def to_h
|
214
|
+
{
|
215
|
+
headers: headers,
|
216
|
+
sensitive: sensitive
|
217
|
+
}
|
218
|
+
end
|
219
|
+
|
220
|
+
def to_json(*args)
|
221
|
+
to_h.to_json(*args)
|
222
|
+
end
|
223
|
+
end
|
224
|
+
end
|
225
|
+
end
|
226
|
+
end
|