class Moip2::WebhooksApi

Attributes

client[R]

Public Class Methods

new(client) click to toggle source
# File lib/moip2/webhooks_api.rb, line 5
def initialize(client)
  @client = client
end

Public Instance Methods

find_all(limit: nil, offset: nil, resource_id: nil, event: nil) click to toggle source
# File lib/moip2/webhooks_api.rb, line 9
def find_all(limit: nil, offset: nil, resource_id: nil, event: nil)
  # `URI.encode...` will accept nil params, but they will pollute the URI
  params = {
    limit: limit,
    offset: offset,
    resourceId: resource_id,
    event: event,
  }.reject { |_, value| value.nil? }

  query_string = URI.encode_www_form(params)
  path = "#{base_path}?#{query_string}"
  response = client.get(path)

  # We need to transform raw JSON in Webhooks objects
  response.webhooks.map! { |webhooks| Resource::Webhooks.new client, webhooks }
  Resource::Webhooks.new client, response
end

Private Instance Methods

base_path() click to toggle source
# File lib/moip2/webhooks_api.rb, line 29
def base_path
  "/v2/webhooks"
end