Module: MangoApi::Hooks

Extended by:
UriProvider
Defined in:
lib/mangopay/api/service/hooks.rb

Overview

Provides API method delegates concerning the Hook entity

Class Method Summary collapse

Methods included from UriProvider

provide_uri

Class Method Details

.allArray

Retrieves all hooks.

Allowed FilterRequest params:

  • page

  • per_page

  • sort_field and sort_direction

Returns:

  • (Array)

    Hook entity objects



64
65
66
67
68
# File 'lib/mangopay/api/service/hooks.rb', line 64

def all
  uri = provide_uri(:get_hooks)
  results = HttpClient.get(uri)
  parse_results results
end

.create(hook, id_key = nil) ⇒ Hook

Creates a new hook entity.

Hook properties:

  • Required

    • event_type

    • url

  • Optional

    • tag

Parameters:

  • +hook+ (Hook)

    model object of the hook to be created

  • +id_key+ (String)

    idempotency key for future response replication

Returns:

  • (Hook)

    the newly-created Hook entity object



23
24
25
26
27
# File 'lib/mangopay/api/service/hooks.rb', line 23

def create(hook, id_key = nil)
  uri = provide_uri(:create_hook)
  response = HttpClient.post(uri, hook, id_key)
  parse response
end

.get(id) ⇒ Hook

Retrieves a hook entity.

Parameters:

  • +id+ (String)

    ID of the hook to retrieve

Returns:

  • (Hook)

    the requested Hook entity object



50
51
52
53
54
# File 'lib/mangopay/api/service/hooks.rb', line 50

def get(id)
  uri = provide_uri(:get_hook, id)
  response = HttpClient.get(uri)
  parse response
end

.update(hook) ⇒ Hook

Updates the hook entity identifiable by the provided Hook object’s ID.

Hook optional properties:

  • tag

  • status

  • url

and updated data

Parameters:

  • +hook+ (Hook)

    hook object with corresponding ID

Returns:

  • (Hook)

    the updated Hook entity object



40
41
42
43
44
# File 'lib/mangopay/api/service/hooks.rb', line 40

def update(hook)
  uri = provide_uri(:update_hook, hook.id)
  response = HttpClient.put(uri, hook)
  parse response
end