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.
@@ -4,7 +4,7 @@
4
4
 
5
5
  module Perata
6
6
  # This SDK's version.
7
- VERSION = "0.5.4"
7
+ VERSION = "0.5.6"
8
8
 
9
9
  # The contract this SDK was generated from.
10
10
  API_VERSION = "0.1.0"
@@ -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
- message = { id: event.fetch("id"), type: event.fetch("type"), timestamp: event.fetch("timestamp"), environment: environment }
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))
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: perata-sdk
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.4
4
+ version: 0.5.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peráta