Class: Pin::Recipient

Inherits:
Base
  • Object
show all
Defined in:
lib/pin_up/recipient.rb

Overview

This class models Pin’s Recipient API

Instance Attribute Summary

Attributes inherited from Base

#key

Class Method Summary collapse

Methods inherited from Base

#base_uri, build_collection_response, build_response, #initialize, make_request

Constructor Details

This class inherits a constructor from Pin::Base

Class Method Details

.all(page = nil, pagination = false) ⇒ Object

Lists all recipients for your account args: page (Fixnum), pagination (Boolean) returns: a collection of recipients

if pagination is passed, access the response hash with [:response] and the pagination hash with [:pagination]

pinpayments.com/docs/api/recipients#get-recipients



23
24
25
# File 'lib/pin_up/recipient.rb', line 23

def self.all(page = nil, pagination = false)
  build_collection_response(make_request(:get, {url: "recipients?page=#{page}" } ), pagination)
end

.create(options) ⇒ Object

Creates a new recipient and returns its details. pinpayments.com/docs/api/recipients#post-recipients args: options (Hash) returns: recipient (Hash)



10
11
12
# File 'lib/pin_up/recipient.rb', line 10

def self.create(options)
  build_response(make_request(:post, { url: 'recipients', options: options }))
end

.find(token) ⇒ Object

Find a recipient for your account given a token args: token (String) returns: a recipient pinpayments.com/docs/api/recipients#get-recipient



32
33
34
# File 'lib/pin_up/recipient.rb', line 32

def self.find(token)
  build_response(make_request(:get, {url: "recipients/#{token}" } ))
end

.transfers(token, pagination = false) ⇒ Object



46
47
48
# File 'lib/pin_up/recipient.rb', line 46

def self.transfers(token, pagination = false)
  build_collection_response(make_request(:get, { url: "recipients/#{token}/transfers" } ), pagination)
end

.update(token, options = {}) ⇒ Object

Update a recipient for your account given a token and any of: email, name, bank_account (hash) args: token (String), options (Hash) returns: a recipient pinpayments.com/docs/api/recipients#put-recipient



42
43
44
# File 'lib/pin_up/recipient.rb', line 42

def self.update(token, options = {})
  build_response(make_request(:put, { url: "recipients/#{token}", options: options }))
end