Class: AdvancedBilling::Webhook
- Defined in:
- lib/advanced_billing/models/webhook.rb
Overview
Webhook Model.
Instance Attribute Summary collapse
-
#accepted_at ⇒ String
Timestamp indicating when the webhook was accepted by the merchant endpoint.
-
#body ⇒ String
The data sent within the webhook post.
-
#created_at ⇒ String
Timestamp indicating when the webhook was created.
-
#event ⇒ String
A string describing which event type produced the given webhook.
-
#id ⇒ Integer
The unique identifier for the webhooks (unique across all of Chargify).
-
#last_error ⇒ String
Text describing the status code and/or error from the last failed attempt to send the Webhook.
-
#last_error_at ⇒ String
Timestamp indicating when the last non-acceptance occurred.
-
#last_sent_at ⇒ String
Timestamp indicating when the most recent attempt was made to send the webhook.
-
#last_sent_url ⇒ String
The url that the endpoint was last sent to.
-
#signature ⇒ String
The calculated webhook signature.
-
#signature_hmac_sha_256 ⇒ String
The calculated HMAC-SHA-256 webhook signature.
-
#successful ⇒ TrueClass | FalseClass
A boolean flag describing whether the webhook was accepted by the webhook endpoint for the most recent attempt.
Class Method Summary collapse
-
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
-
.names ⇒ Object
A mapping from model property names to API property names.
-
.nullables ⇒ Object
An array for nullable fields.
-
.optionals ⇒ Object
An array for optional fields.
Instance Method Summary collapse
-
#initialize(event = SKIP, id = SKIP, created_at = SKIP, last_error = SKIP, last_error_at = SKIP, accepted_at = SKIP, last_sent_at = SKIP, last_sent_url = SKIP, successful = SKIP, body = SKIP, signature = SKIP, signature_hmac_sha_256 = SKIP) ⇒ Webhook
constructor
A new instance of Webhook.
Methods inherited from BaseModel
Constructor Details
#initialize(event = SKIP, id = SKIP, created_at = SKIP, last_error = SKIP, last_error_at = SKIP, accepted_at = SKIP, last_sent_at = SKIP, last_sent_url = SKIP, successful = SKIP, body = SKIP, signature = SKIP, signature_hmac_sha_256 = SKIP) ⇒ Webhook
Returns a new instance of Webhook.
113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 |
# File 'lib/advanced_billing/models/webhook.rb', line 113 def initialize(event = SKIP, id = SKIP, created_at = SKIP, last_error = SKIP, last_error_at = SKIP, accepted_at = SKIP, last_sent_at = SKIP, last_sent_url = SKIP, successful = SKIP, body = SKIP, signature = SKIP, signature_hmac_sha_256 = SKIP) @event = event unless event == SKIP @id = id unless id == SKIP @created_at = created_at unless created_at == SKIP @last_error = last_error unless last_error == SKIP @last_error_at = last_error_at unless last_error_at == SKIP @accepted_at = accepted_at unless accepted_at == SKIP @last_sent_at = last_sent_at unless last_sent_at == SKIP @last_sent_url = last_sent_url unless last_sent_url == SKIP @successful = successful unless successful == SKIP @body = body unless body == SKIP @signature = signature unless signature == SKIP @signature_hmac_sha_256 = signature_hmac_sha_256 unless signature_hmac_sha_256 == SKIP end |
Instance Attribute Details
#accepted_at ⇒ String
Timestamp indicating when the webhook was accepted by the merchant endpoint. When a webhook is explicitly replayed by the merchant, this value will be cleared until it is accepted again.
41 42 43 |
# File 'lib/advanced_billing/models/webhook.rb', line 41 def accepted_at @accepted_at end |
#body ⇒ String
The data sent within the webhook post
60 61 62 |
# File 'lib/advanced_billing/models/webhook.rb', line 60 def body @body end |
#created_at ⇒ String
Timestamp indicating when the webhook was created
24 25 26 |
# File 'lib/advanced_billing/models/webhook.rb', line 24 def created_at @created_at end |
#event ⇒ String
A string describing which event type produced the given webhook
14 15 16 |
# File 'lib/advanced_billing/models/webhook.rb', line 14 def event @event end |
#id ⇒ Integer
The unique identifier for the webhooks (unique across all of Chargify). This is not changed on a retry/replay of the same webhook, so it may be used to avoid duplicate action for the same event.
20 21 22 |
# File 'lib/advanced_billing/models/webhook.rb', line 20 def id @id end |
#last_error ⇒ String
Text describing the status code and/or error from the last failed attempt to send the Webhook. When a webhook is retried and accepted, this field will be cleared.
30 31 32 |
# File 'lib/advanced_billing/models/webhook.rb', line 30 def last_error @last_error end |
#last_error_at ⇒ String
Timestamp indicating when the last non-acceptance occurred. If a webhook is later resent and accepted, this field will be cleared.
35 36 37 |
# File 'lib/advanced_billing/models/webhook.rb', line 35 def last_error_at @last_error_at end |
#last_sent_at ⇒ String
Timestamp indicating when the most recent attempt was made to send the webhook
46 47 48 |
# File 'lib/advanced_billing/models/webhook.rb', line 46 def last_sent_at @last_sent_at end |
#last_sent_url ⇒ String
The url that the endpoint was last sent to.
50 51 52 |
# File 'lib/advanced_billing/models/webhook.rb', line 50 def last_sent_url @last_sent_url end |
#signature ⇒ String
The calculated webhook signature
64 65 66 |
# File 'lib/advanced_billing/models/webhook.rb', line 64 def signature @signature end |
#signature_hmac_sha_256 ⇒ String
The calculated HMAC-SHA-256 webhook signature
68 69 70 |
# File 'lib/advanced_billing/models/webhook.rb', line 68 def signature_hmac_sha_256 @signature_hmac_sha_256 end |
#successful ⇒ TrueClass | FalseClass
A boolean flag describing whether the webhook was accepted by the webhook endpoint for the most recent attempt. (Acceptance is defined by receiving a “200 OK” HTTP response within a reasonable timeframe, i.e. 15 seconds)
56 57 58 |
# File 'lib/advanced_billing/models/webhook.rb', line 56 def successful @successful end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 |
# File 'lib/advanced_billing/models/webhook.rb', line 132 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. event = hash.key?('event') ? hash['event'] : SKIP id = hash.key?('id') ? hash['id'] : SKIP created_at = hash.key?('created_at') ? hash['created_at'] : SKIP last_error = hash.key?('last_error') ? hash['last_error'] : SKIP last_error_at = hash.key?('last_error_at') ? hash['last_error_at'] : SKIP accepted_at = hash.key?('accepted_at') ? hash['accepted_at'] : SKIP last_sent_at = hash.key?('last_sent_at') ? hash['last_sent_at'] : SKIP last_sent_url = hash.key?('last_sent_url') ? hash['last_sent_url'] : SKIP successful = hash.key?('successful') ? hash['successful'] : SKIP body = hash.key?('body') ? hash['body'] : SKIP signature = hash.key?('signature') ? hash['signature'] : SKIP signature_hmac_sha_256 = hash.key?('signature_hmac_sha_256') ? hash['signature_hmac_sha_256'] : SKIP # Create object from extracted values. Webhook.new(event, id, created_at, last_error, last_error_at, accepted_at, last_sent_at, last_sent_url, successful, body, signature, signature_hmac_sha_256) end |
.names ⇒ Object
A mapping from model property names to API property names.
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/advanced_billing/models/webhook.rb', line 71 def self.names @_hash = {} if @_hash.nil? @_hash['event'] = 'event' @_hash['id'] = 'id' @_hash['created_at'] = 'created_at' @_hash['last_error'] = 'last_error' @_hash['last_error_at'] = 'last_error_at' @_hash['accepted_at'] = 'accepted_at' @_hash['last_sent_at'] = 'last_sent_at' @_hash['last_sent_url'] = 'last_sent_url' @_hash['successful'] = 'successful' @_hash['body'] = 'body' @_hash['signature'] = 'signature' @_hash['signature_hmac_sha_256'] = 'signature_hmac_sha_256' @_hash end |
.nullables ⇒ Object
An array for nullable fields
107 108 109 110 111 |
# File 'lib/advanced_billing/models/webhook.rb', line 107 def self.nullables %w[ accepted_at ] end |
.optionals ⇒ Object
An array for optional fields
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 |
# File 'lib/advanced_billing/models/webhook.rb', line 89 def self.optionals %w[ event id created_at last_error last_error_at accepted_at last_sent_at last_sent_url successful body signature signature_hmac_sha_256 ] end |