Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,22 @@ class WebhooksController < ApplicationController
end
```

#### Accessing the webhook ID

If you need to access the webhook ID for debugging purposes, you can use `parse_with_meta` instead:

```ruby
result = GoCardlessPro::Webhook.parse_with_meta(
request_body: request.raw_post,
signature_header: request.headers['Webhook-Signature'],
webhook_endpoint_secret: webhook_endpoint_secret
)
events = result.events
webhook_id = result.webhook_id # e.g. "WB123" - useful for debugging
```

Note: The webhook ID is intended for debugging and logging purposes only. It should not be used for deduplication - instead, use the event IDs to deduplicate, as each event has a unique ID that remains consistent if the same event is sent multiple times.

For more details on working with webhooks, see our ["Getting started" guide](https://developer.gocardless.com/getting-started/api/introduction/?lang=ruby).

### Using the OAuth API
Expand Down
6 changes: 6 additions & 0 deletions lib/gocardless_pro.rb
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,12 @@ module GoCardlessPro
require_relative 'gocardless_pro/resources/outbound_payment'
require_relative 'gocardless_pro/services/outbound_payments_service'

require_relative 'gocardless_pro/resources/outbound_payment_import'
require_relative 'gocardless_pro/services/outbound_payment_imports_service'

require_relative 'gocardless_pro/resources/outbound_payment_import_entry'
require_relative 'gocardless_pro/services/outbound_payment_import_entries_service'

require_relative 'gocardless_pro/resources/payer_authorisation'
require_relative 'gocardless_pro/services/payer_authorisations_service'

Expand Down
12 changes: 11 additions & 1 deletion lib/gocardless_pro/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,16 @@ def outbound_payments
@outbound_payments ||= Services::OutboundPaymentsService.new(@api_service)
end

# Access to the service for outbound_payment_import to make API calls
def outbound_payment_imports
@outbound_payment_imports ||= Services::OutboundPaymentImportsService.new(@api_service)
end

# Access to the service for outbound_payment_import_entry to make API calls
def outbound_payment_import_entries
@outbound_payment_import_entries ||= Services::OutboundPaymentImportEntriesService.new(@api_service)
end

# Access to the service for payer_authorisation to make API calls
def payer_authorisations
@payer_authorisations ||= Services::PayerAuthorisationsService.new(@api_service)
Expand Down Expand Up @@ -273,7 +283,7 @@ def default_options
'User-Agent' => "#{user_agent}",
'Content-Type' => 'application/json',
'GoCardless-Client-Library' => 'gocardless-pro-ruby',
'GoCardless-Client-Version' => '4.3.0',
'GoCardless-Client-Version' => '4.4.0',
},
}
end
Expand Down
4 changes: 2 additions & 2 deletions lib/gocardless_pro/list_response.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ def api_response

# return the before cursor for paginating
def before
@response.body['meta']['cursors']['before']
@response.body.dig('meta', 'cursors', 'before')
end

# return the after cursor for paginating
def after
@response.body['meta']['cursors']['after']
@response.body.dig('meta', 'cursors', 'after')
end
end
end
2 changes: 2 additions & 0 deletions lib/gocardless_pro/resources/customer_bank_account.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ class CustomerBankAccount
attr_reader :enabled
attr_reader :id
attr_reader :metadata
attr_reader :trusted_recipient

# Initialize a customer_bank_account resource instance
# @param object [Hash] an object returned from the API
Expand All @@ -57,6 +58,7 @@ def initialize(object, response = nil)
@id = object['id']
@links = object['links']
@metadata = object['metadata']
@trusted_recipient = object['trusted_recipient']
@response = response
end

Expand Down
2 changes: 2 additions & 0 deletions lib/gocardless_pro/resources/export.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class Export
attr_reader :created_at
attr_reader :currency
attr_reader :download_url
attr_reader :error_message
attr_reader :export_type
attr_reader :id

Expand All @@ -26,6 +27,7 @@ def initialize(object, response = nil)
@created_at = object['created_at']
@currency = object['currency']
@download_url = object['download_url']
@error_message = object['error_message']
@export_type = object['export_type']
@id = object['id']
@response = response
Expand Down
2 changes: 2 additions & 0 deletions lib/gocardless_pro/resources/mandate.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class Mandate
attr_reader :created_at
attr_reader :funds_settlement
attr_reader :id
attr_reader :mandate_type
attr_reader :metadata
attr_reader :next_possible_charge_date
attr_reader :next_possible_standard_ach_charge_date
Expand All @@ -43,6 +44,7 @@ def initialize(object, response = nil)
@funds_settlement = object['funds_settlement']
@id = object['id']
@links = object['links']
@mandate_type = object['mandate_type']
@metadata = object['metadata']
@next_possible_charge_date = object['next_possible_charge_date']
@next_possible_standard_ach_charge_date = object['next_possible_standard_ach_charge_date']
Expand Down
81 changes: 81 additions & 0 deletions lib/gocardless_pro/resources/outbound_payment_import.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
#
# This client is automatically generated from a template and JSON schema definition.
# See https://github.com/gocardless/gocardless-pro-ruby#contributing before editing.
#

require 'uri'

module GoCardlessPro
# A module containing classes for each of the resources in the GC Api
module Resources
# Represents an instance of a outbound_payment_import resource returned from the API

# Outbound Payment Imports allow you to create multiple payments via a
# single API call.
#
# The Workflow:
# 1. Create the outbound payment import.
# 2. Retrieve an authorisation link from the response.
# 3. Redirect the user to the link to authorise the import.
# 4. Once the user authorises the import, the individual outbound payments
# are automatically submitted.
#
# Import entries are not processed as actual payments until they are
# reviewed and authorised in GoCardless Dashboard.
# Upon approval, a unique outbound payment is generated for every entry in
# the import.
#
# <p class="notice">Outbound Payment Imports are capped at 1000 entries. If
# you expect to exceed this limit, please create multiple smaller
# imports.</p>
class OutboundPaymentImport
attr_reader :amount_sum
attr_reader :authorisation_url
attr_reader :created_at
attr_reader :currency
attr_reader :entry_counts
attr_reader :id
attr_reader :status

# Initialize a outbound_payment_import resource instance
# @param object [Hash] an object returned from the API
def initialize(object, response = nil)
@object = object

@amount_sum = object['amount_sum']
@authorisation_url = object['authorisation_url']
@created_at = object['created_at']
@currency = object['currency']
@entry_counts = object['entry_counts']
@id = object['id']
@links = object['links']
@status = object['status']
@response = response
end

def api_response
ApiResponse.new(@response)
end

# Return the links that the resource has
def links
@outbound_payment_import_links ||= Links.new(@links)
end

# Provides the outbound_payment_import resource as a hash of all its readable attributes
def to_h
@object
end

class Links
def initialize(links)
@links = links || {}
end

def creditor
@links['creditor']
end
end
end
end
end
77 changes: 77 additions & 0 deletions lib/gocardless_pro/resources/outbound_payment_import_entry.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
#
# This client is automatically generated from a template and JSON schema definition.
# See https://github.com/gocardless/gocardless-pro-ruby#contributing before editing.
#

require 'uri'

module GoCardlessPro
# A module containing classes for each of the resources in the GC Api
module Resources
# Represents an instance of a outbound_payment_import_entry resource returned from the API

# Import Entries are the individual rows of an outbound payment import,
# representing each payment to be created.
class OutboundPaymentImportEntry
attr_reader :amount
attr_reader :created_at
attr_reader :id
attr_reader :metadata
attr_reader :processed_at
attr_reader :reference
attr_reader :scheme
attr_reader :validation_errors
attr_reader :verification_result

# Initialize a outbound_payment_import_entry resource instance
# @param object [Hash] an object returned from the API
def initialize(object, response = nil)
@object = object

@amount = object['amount']
@created_at = object['created_at']
@id = object['id']
@links = object['links']
@metadata = object['metadata']
@processed_at = object['processed_at']
@reference = object['reference']
@scheme = object['scheme']
@validation_errors = object['validation_errors']
@verification_result = object['verification_result']
@response = response
end

def api_response
ApiResponse.new(@response)
end

# Return the links that the resource has
def links
@outbound_payment_import_entry_links ||= Links.new(@links)
end

# Provides the outbound_payment_import_entry resource as a hash of all its readable attributes
def to_h
@object
end

class Links
def initialize(links)
@links = links || {}
end

def outbound_payment
@links['outbound_payment']
end

def outbound_payment_import
@links['outbound_payment_import']
end

def recipient_bank_account
@links['recipient_bank_account']
end
end
end
end
end
3 changes: 1 addition & 2 deletions lib/gocardless_pro/services/billing_requests_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -329,8 +329,7 @@ def get(identity, options = {})
# it.
# Currently, the customer can only be notified by email.
#
# This endpoint is currently supported only for Instant Bank Pay Billing
# Requests.
# This endpoint is currently supported only for Pay by Bank Billing Requests.
# Example URL: /billing_requests/:identity/actions/notify
#
# @param identity # Unique identifier, beginning with "BRQ".
Expand Down
2 changes: 1 addition & 1 deletion lib/gocardless_pro/services/mandate_pdfs_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class MandatePdfsService < BaseService
#
# To generate a PDF mandate in another language, set the `Accept-Language`
# header when creating the PDF mandate to the relevant [ISO
# 639-1](http://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) language code
# 639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) language code
# supported for the scheme.
#
# | Scheme | Supported languages
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
require_relative './base_service'

# encoding: utf-8
#
# This client is automatically generated from a template and JSON schema definition.
# See https://github.com/gocardless/gocardless-pro-ruby#contributing before editing.
#

module GoCardlessPro
module Services
# Service for making requests to the OutboundPaymentImportEntry endpoints
class OutboundPaymentImportEntriesService < BaseService
# Returns a [cursor-paginated](#api-usage-cursor-pagination) list of the entries
# for a given outbound payment import.
# Example URL: /outbound_payment_import_entries
# @param options [Hash] parameters as a hash, under a params key.
def list(options = {})
path = '/outbound_payment_import_entries'

options[:retry_failures] = true

response = make_request(:get, path, options)

ListResponse.new(
response: response,
unenveloped_body: unenvelope_body(response.body),
resource_class: Resources::OutboundPaymentImportEntry
)
end

# Get a lazily enumerated list of all the items returned. This is similar to the `list` method but will paginate for you automatically.
#
# @param options [Hash] parameters as a hash. If the request is a GET, these will be converted to query parameters.
# Otherwise they will be the body of the request.
def all(options = {})
Paginator.new(
service: self,
options: options
).enumerator
end

private

# Unenvelope the response of the body using the service's `envelope_key`
#
# @param body [Hash]
def unenvelope_body(body)
body[envelope_key] || body['data']
end

# return the key which API responses will envelope data under
def envelope_key
'outbound_payment_import_entries'
end
end
end
end
Loading