Class: EInvoiceAPI::Resources::Webhooks

Inherits:
Object
  • Object
show all
Defined in:
lib/e_invoice_api/resources/webhooks.rb

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Webhooks

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 Webhooks.

Parameters:



112
113
114
# File 'lib/e_invoice_api/resources/webhooks.rb', line 112

def initialize(client:)
  @client = client
end

Instance Method Details

#create(events: , url: , enabled: nil, request_options: {}) ⇒ EInvoiceAPI::Models::WebhookResponse

Create a new webhook

Parameters:

Returns:

See Also:



18
19
20
21
22
23
24
25
26
27
# File 'lib/e_invoice_api/resources/webhooks.rb', line 18

def create(params)
  parsed, options = EInvoiceAPI::WebhookCreateParams.dump_request(params)
  @client.request(
    method: :post,
    path: "api/webhooks/",
    body: parsed,
    model: EInvoiceAPI::WebhookResponse,
    options: options
  )
end

#delete(webhook_id, request_options: {}) ⇒ EInvoiceAPI::Models::WebhookDeleteResponse

Delete a webhook

Parameters:

Returns:

See Also:



100
101
102
103
104
105
106
107
# File 'lib/e_invoice_api/resources/webhooks.rb', line 100

def delete(webhook_id, params = {})
  @client.request(
    method: :delete,
    path: ["api/webhooks/%1$s", webhook_id],
    model: EInvoiceAPI::Models::WebhookDeleteResponse,
    options: params[:request_options]
  )
end

#list(request_options: {}) ⇒ Array<EInvoiceAPI::Models::WebhookResponse>

Get all webhooks for the current tenant

Parameters:

Returns:

See Also:



81
82
83
84
85
86
87
88
# File 'lib/e_invoice_api/resources/webhooks.rb', line 81

def list(params = {})
  @client.request(
    method: :get,
    path: "api/webhooks/",
    model: EInvoiceAPI::Internal::Type::ArrayOf[EInvoiceAPI::WebhookResponse],
    options: params[:request_options]
  )
end

#retrieve(webhook_id, request_options: {}) ⇒ EInvoiceAPI::Models::WebhookResponse

Get a webhook by ID

Parameters:

Returns:

See Also:



39
40
41
42
43
44
45
46
# File 'lib/e_invoice_api/resources/webhooks.rb', line 39

def retrieve(webhook_id, params = {})
  @client.request(
    method: :get,
    path: ["api/webhooks/%1$s", webhook_id],
    model: EInvoiceAPI::WebhookResponse,
    options: params[:request_options]
  )
end

#update(webhook_id, enabled: nil, events: nil, url: nil, request_options: {}) ⇒ EInvoiceAPI::Models::WebhookResponse

Update a webhook by ID

Parameters:

  • webhook_id (String)
  • enabled (Boolean, nil)
  • events (Array<String>, nil)
  • url (String, nil)
  • request_options (EInvoiceAPI::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



61
62
63
64
65
66
67
68
69
70
# File 'lib/e_invoice_api/resources/webhooks.rb', line 61

def update(webhook_id, params = {})
  parsed, options = EInvoiceAPI::WebhookUpdateParams.dump_request(params)
  @client.request(
    method: :put,
    path: ["api/webhooks/%1$s", webhook_id],
    body: parsed,
    model: EInvoiceAPI::WebhookResponse,
    options: options
  )
end