Class: Sydecar::Subscription

Inherits:
Object
  • Object
show all
Defined in:
lib/sydecar/subscription.rb

Constant Summary collapse

URL =
'/v1/subscriptions'
CREATE_URL =
"#{URL}/create"
FUNDING_COUNTRIES_URL =
'/v1/subscriptions/funding_countries'

Class Method Summary collapse

Class Method Details

.amend(id:, body:) ⇒ Object

Parameters:

  • id (UUID)
  • body (Hash)


89
90
91
92
# File 'lib/sydecar/subscription.rb', line 89

def amend(id:, body:)
  url = amend_url(id: id)
  Connection.instance.post(url, body)
end

.amend_url(id:) ⇒ Object



83
84
85
# File 'lib/sydecar/subscription.rb', line 83

def amend_url(id:)
  "/v1/subscriptions/#{id}/amend"
end

.create(body:, idempotency_key:) ⇒ Object

Parameters:

  • body (Hash)
  • idempotency_key (UUID)


12
13
14
# File 'lib/sydecar/subscription.rb', line 12

def create(body:, idempotency_key:)
  Connection.instance.post(CREATE_URL, body, { 'idempotency-key': idempotency_key })
end

.create_agreement_preview(id:) ⇒ Object

Parameters:

  • id (UUID)


42
43
44
45
# File 'lib/sydecar/subscription.rb', line 42

def create_agreement_preview(id:)
  url = create_agreement_preview_url(id: id)
  Connection.instance.post(url)
end

.create_agreement_preview_url(id:) ⇒ Object

Parameters:

  • id (UUID)


37
38
39
# File 'lib/sydecar/subscription.rb', line 37

def create_agreement_preview_url(id:)
  "/v1/subscriptions/#{id}/subscription_agreement/preview?streamable_file=true"
end

.create_virtual_bank_account(id:, body:) ⇒ Object

Parameters:

  • id (UUID)
  • body (Hash)


54
55
56
57
# File 'lib/sydecar/subscription.rb', line 54

def (id:, body:)
  url = (id: id)
  Connection.instance.post(url, body)
end

.create_virtual_bank_account_url(id:) ⇒ Object

Parameters:

  • id (UUID)


48
49
50
# File 'lib/sydecar/subscription.rb', line 48

def (id:)
  "/v1/subscriptions/#{id}/create_account"
end

.delete(id:) ⇒ Object

Parameters:

  • id (UUID)


32
33
34
# File 'lib/sydecar/subscription.rb', line 32

def delete(id:)
  Connection.instance.delete("#{URL}/#{id}")
end

.finalize(id:, body:) ⇒ Object

‘id’ [String] id of subscriber body [Hash] argument expects to have the following keys: document_signer: { “name”: [String], “title”: [String] }

"name"  The name of the signer.
"title"  The title of the signer as relates to the entity it represents.

Finalize a subscription to be ready to create a bank account.

Parameters:



161
162
163
164
# File 'lib/sydecar/subscription.rb', line 161

def finalize(id:, body:)
  url = url id
  Connection.instance.post(url, body)
end

.find(id:) ⇒ Object

Parameters:

  • id (UUID)


21
22
23
# File 'lib/sydecar/subscription.rb', line 21

def find(id:)
  Connection.instance.get("#{URL}/#{id}", { reveal_bank_info: true, include: 'ach_transfers' })
end

.find_all(params: {}, body: {}) ⇒ Object

String

sort: asc / desc

Integer

limit

Integer

offset

String

start_date (format: yyyy-mm-dd)

String

end_date (format: yyyy-mm-dd)

Boolean

reveal_bank_info

String

include (example: ‘ach_transfers’)

Parameters:

  • params (Hash) (defaults to: {})

    argument expects to have the following keys:

  • body: (Hash) (defaults to: {})

    expects to have “ids” key



142
143
144
145
146
# File 'lib/sydecar/subscription.rb', line 142

def find_all(params: {}, body: {})
  query = '?'
  query += URI.encode_www_form(params)
  Connection.instance.post("#{URL}#{query}", body)
end

.funding_countries_listObject



16
17
18
# File 'lib/sydecar/subscription.rb', line 16

def funding_countries_list
  Connection.instance.get(FUNDING_COUNTRIES_URL)
end

.refund(id:, body:, idempotency_key:) ⇒ Object

Parameters:

  • id (UUID)
  • body (Hash)
  • idempotency_key (UUID)


128
129
130
131
# File 'lib/sydecar/subscription.rb', line 128

def refund(id:, body:, idempotency_key:)
  url = refund_url(id: id)
  Connection.instance.post(url, body, { 'idempotency-key': idempotency_key })
end

.refund_ach_with_plaid(id:, body:, idempotency_key:) ⇒ Object

Parameters:

  • id (UUID)
  • body (Hash)
  • idempotency_key (UUID)


115
116
117
118
# File 'lib/sydecar/subscription.rb', line 115

def refund_ach_with_plaid(id:, body:, idempotency_key:)
  url = refund_ach_with_plaid_url(id: id)
  Connection.instance.post(url, body, { 'idempotency-key': idempotency_key })
end

.refund_ach_with_plaid_url(id:) ⇒ Object

Parameters:

  • id (UUID)


108
109
110
# File 'lib/sydecar/subscription.rb', line 108

def refund_ach_with_plaid_url(id:)
  "/v1/subscriptions/#{id}/refund_ach_with_plaid"
end

.refund_url(id:) ⇒ Object

Parameters:

  • id (UUID)


121
122
123
# File 'lib/sydecar/subscription.rb', line 121

def refund_url(id:)
  "/v1/subscriptions/#{id}/refund"
end

.send_ach_with_plaid(id:, body:, idempotency_key:) ⇒ Object

Parameters:

  • id (UUID)
  • body (Hash)
  • idempotency_key (UUID)


102
103
104
105
# File 'lib/sydecar/subscription.rb', line 102

def send_ach_with_plaid(id:, body:, idempotency_key:)
  url = send_ach_with_plaid_url(id: id)
  Connection.instance.post(url, body, { 'idempotency-key': idempotency_key })
end

.send_ach_with_plaid_url(id:) ⇒ Object

Parameters:

  • id (UUID)


95
96
97
# File 'lib/sydecar/subscription.rb', line 95

def send_ach_with_plaid_url(id:)
  "/v1/subscriptions/#{id}/send_ach_with_plaid"
end

.set_balance(id:, body:) ⇒ Object

Parameters:

  • id (UUID)
  • body (Hash)


66
67
68
69
# File 'lib/sydecar/subscription.rb', line 66

def set_balance(id:, body:)
  url = set_balance_url(id: id)
  Connection.instance.post(url, body)
end

.set_balance_url(id:) ⇒ Object

Parameters:

  • id (UUID)


60
61
62
# File 'lib/sydecar/subscription.rb', line 60

def set_balance_url(id:)
  "/v1/subscriptions/#{id}/fund"
end

.sign(id:, body:) ⇒ Object

Parameters:

  • id (UUID)
  • body (Hash)


78
79
80
81
# File 'lib/sydecar/subscription.rb', line 78

def sign(id:, body:)
  url = sign_url(id: id)
  Connection.instance.post(url, body)
end

.sign_url(id:) ⇒ Object

Parameters:

  • id (UUID)


72
73
74
# File 'lib/sydecar/subscription.rb', line 72

def sign_url(id:)
  "/v1/subscriptions/#{id}/sign"
end

.update(id:, body:) ⇒ Object

Parameters:

  • id (UUID)
  • body (Hash)


27
28
29
# File 'lib/sydecar/subscription.rb', line 27

def update(id:, body:)
  Connection.instance.patch("#{URL}/#{id}", body)
end

.url(id) ⇒ Object



148
149
150
# File 'lib/sydecar/subscription.rb', line 148

def url(id)
  "#{URL}/#{id}/finalize"
end