Class: Increase::Resources::Events
- Inherits:
-
Object
- Object
- Increase::Resources::Events
- Defined in:
- lib/increase/resources/events.rb
Instance Method Summary collapse
-
#initialize(client:) ⇒ Events
constructor
private
A new instance of Events.
-
#list(associated_object_id: nil, category: nil, created_at: nil, cursor: nil, limit: nil, request_options: {}) ⇒ Increase::Internal::Page<Increase::Models::Event>
Some parameter documentations has been truncated, see Models::EventListParams for more details.
-
#retrieve(event_id, request_options: {}) ⇒ Increase::Models::Event
Retrieve an Event.
- #unwrap(payload, headers:, key: @client.webhook_secret) ⇒ Increase::Models::UnwrapWebhookEvent
Constructor Details
#initialize(client:) ⇒ Events
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Events.
82 83 84 |
# File 'lib/increase/resources/events.rb', line 82 def initialize(client:) @client = client end |
Instance Method Details
#list(associated_object_id: nil, category: nil, created_at: nil, cursor: nil, limit: nil, request_options: {}) ⇒ Increase::Internal::Page<Increase::Models::Event>
Some parameter documentations has been truncated, see Models::EventListParams for more details.
List Events
48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/increase/resources/events.rb', line 48 def list(params = {}) parsed, = Increase::EventListParams.dump_request(params) query = Increase::Internal::Util.encode_query_params(parsed) @client.request( method: :get, path: "events", query: query, page: Increase::Internal::Page, model: Increase::Event, options: ) end |
#retrieve(event_id, request_options: {}) ⇒ Increase::Models::Event
Retrieve an Event
17 18 19 20 21 22 23 24 |
# File 'lib/increase/resources/events.rb', line 17 def retrieve(event_id, params = {}) @client.request( method: :get, path: ["events/%1$s", event_id], model: Increase::Event, options: params[:request_options] ) end |
#unwrap(payload, headers:, key: @client.webhook_secret) ⇒ Increase::Models::UnwrapWebhookEvent
68 69 70 71 72 73 74 75 76 77 |
# File 'lib/increase/resources/events.rb', line 68 def unwrap(payload, headers:, key: @client.webhook_secret) if key.nil? raise ArgumentError.new("Cannot verify a webhook without a key on either the client's webhook_secret or passed in as an argument") end ::StandardWebhooks::Webhook.new(Base64.strict_encode64(key)).verify(payload, headers) parsed = JSON.parse(payload, symbolize_names: true) Increase::Internal::Type::Converter.coerce(Increase::Models::UnwrapWebhookEvent, parsed) end |