perata-sdk 0.5.4 → 0.5.6
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.
- checksums.yaml +4 -4
- data/README.md +68 -4
- data/lib/perata/client.rb +12 -1
- data/lib/perata/models.rb +308 -34
- data/lib/perata/params.rb +44 -16
- data/lib/perata/services.rb +651 -73
- data/lib/perata/version.rb +1 -1
- data/lib/perata/webhooks.rb +8 -3
- metadata +1 -1
data/lib/perata/version.rb
CHANGED
data/lib/perata/webhooks.rb
CHANGED
|
@@ -21,7 +21,7 @@ module Perata
|
|
|
21
21
|
# (OrderWebhookEvent carries a WebhookOrder…), or UnknownWebhookEvent for a type
|
|
22
22
|
# this SDK does not know yet. Within a class, +type+ says what happened.
|
|
23
23
|
class WebhookEvent < Model
|
|
24
|
-
MEMBERS = %i[id type timestamp environment data].freeze
|
|
24
|
+
MEMBERS = %i[id type timestamp environment showcase_id data].freeze
|
|
25
25
|
|
|
26
26
|
# @return [String] the message's id, the same as the webhook-id header
|
|
27
27
|
attr_reader :id
|
|
@@ -32,14 +32,18 @@ module Perata
|
|
|
32
32
|
# @return [String] the environment it happened in, "test" or "live"; empty
|
|
33
33
|
# when an older server did not send it
|
|
34
34
|
attr_reader :environment
|
|
35
|
+
# @return [String] the showcase of the sale, the same +showcase_id+ the
|
|
36
|
+
# API's objects carry; empty when an older server did not send it
|
|
37
|
+
attr_reader :showcase_id
|
|
35
38
|
# @return [Object] what the event carries
|
|
36
39
|
attr_reader :data
|
|
37
40
|
|
|
38
|
-
def initialize(id:, type:, timestamp:, data:, environment: "")
|
|
41
|
+
def initialize(id:, type:, timestamp:, data:, environment: "", showcase_id: "")
|
|
39
42
|
@id = id
|
|
40
43
|
@type = type
|
|
41
44
|
@timestamp = timestamp
|
|
42
45
|
@environment = environment
|
|
46
|
+
@showcase_id = showcase_id
|
|
43
47
|
@data = data
|
|
44
48
|
freeze
|
|
45
49
|
end
|
|
@@ -163,7 +167,8 @@ module Perata
|
|
|
163
167
|
event = JSON.parse(raw)
|
|
164
168
|
data = event["data"] || {}
|
|
165
169
|
environment = event["environment"].is_a?(String) ? event["environment"] : ""
|
|
166
|
-
|
|
170
|
+
showcase_id = event["showcase_id"].is_a?(String) ? event["showcase_id"] : ""
|
|
171
|
+
message = { id: event.fetch("id"), type: event.fetch("type"), timestamp: event.fetch("timestamp"), environment: environment, showcase_id: showcase_id }
|
|
167
172
|
case message[:type]
|
|
168
173
|
when *BenefitWebhookEvent::TYPES then BenefitWebhookEvent.new(**message, data: WebhookBenefit.from_hash(data))
|
|
169
174
|
when *BenefitGrantWebhookEvent::TYPES then BenefitGrantWebhookEvent.new(**message, data: BenefitGrant.from_hash(data))
|