sydecar 0.1.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,167 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Sydecar
4
+ class Subscription
5
+ URL = '/v1/subscriptions'
6
+ CREATE_URL = "#{URL}/create"
7
+ FUNDING_COUNTRIES_URL = '/v1/subscriptions/funding_countries'
8
+
9
+ class << self
10
+ # @param [Hash] body
11
+ # @param [UUID] idempotency_key
12
+ def create(body:, idempotency_key:)
13
+ Connection.instance.post(CREATE_URL, body, { 'idempotency-key': idempotency_key })
14
+ end
15
+
16
+ def funding_countries_list
17
+ Connection.instance.get(FUNDING_COUNTRIES_URL)
18
+ end
19
+
20
+ # @param [UUID] id
21
+ def find(id:)
22
+ Connection.instance.get("#{URL}/#{id}", { reveal_bank_info: true, include: 'ach_transfers' })
23
+ end
24
+
25
+ # @param [UUID] id
26
+ # @param [Hash] body
27
+ def update(id:, body:)
28
+ Connection.instance.patch("#{URL}/#{id}", body)
29
+ end
30
+
31
+ # @param [UUID] id
32
+ def delete(id:)
33
+ Connection.instance.delete("#{URL}/#{id}")
34
+ end
35
+
36
+ # @param [UUID] id
37
+ def create_agreement_preview_url(id:)
38
+ "/v1/subscriptions/#{id}/subscription_agreement/preview?streamable_file=true"
39
+ end
40
+
41
+ # @param [UUID] id
42
+ def create_agreement_preview(id:)
43
+ url = create_agreement_preview_url(id: id)
44
+ Connection.instance.post(url)
45
+ end
46
+
47
+ # @param [UUID] id
48
+ def create_virtual_bank_account_url(id:)
49
+ "/v1/subscriptions/#{id}/create_account"
50
+ end
51
+
52
+ # @param [UUID] id
53
+ # @param [Hash] body
54
+ def create_virtual_bank_account(id:, body:)
55
+ url = create_virtual_bank_account_url(id: id)
56
+ Connection.instance.post(url, body)
57
+ end
58
+
59
+ # @param [UUID] id
60
+ def set_balance_url(id:)
61
+ "/v1/subscriptions/#{id}/fund"
62
+ end
63
+
64
+ # @param [UUID] id
65
+ # @param [Hash] body
66
+ def set_balance(id:, body:)
67
+ url = set_balance_url(id: id)
68
+ Connection.instance.post(url, body)
69
+ end
70
+
71
+ # @param [UUID] id
72
+ def sign_url(id:)
73
+ "/v1/subscriptions/#{id}/sign"
74
+ end
75
+
76
+ # @param [UUID] id
77
+ # @param [Hash] body
78
+ def sign(id:, body:)
79
+ url = sign_url(id: id)
80
+ Connection.instance.post(url, body)
81
+ end
82
+
83
+ def amend_url(id:)
84
+ "/v1/subscriptions/#{id}/amend"
85
+ end
86
+
87
+ # @param [UUID] id
88
+ # @param [Hash] body
89
+ def amend(id:, body:)
90
+ url = amend_url(id: id)
91
+ Connection.instance.post(url, body)
92
+ end
93
+
94
+ # @param [UUID] id
95
+ def send_ach_with_plaid_url(id:)
96
+ "/v1/subscriptions/#{id}/send_ach_with_plaid"
97
+ end
98
+
99
+ # @param [UUID] id
100
+ # @param [Hash] body
101
+ # @param [UUID] idempotency_key
102
+ def send_ach_with_plaid(id:, body:, idempotency_key:)
103
+ url = send_ach_with_plaid_url(id: id)
104
+ Connection.instance.post(url, body, { 'idempotency-key': idempotency_key })
105
+ end
106
+
107
+ # @param [UUID] id
108
+ def refund_ach_with_plaid_url(id:)
109
+ "/v1/subscriptions/#{id}/refund_ach_with_plaid"
110
+ end
111
+
112
+ # @param [UUID] id
113
+ # @param [Hash] body
114
+ # @param [UUID] idempotency_key
115
+ def refund_ach_with_plaid(id:, body:, idempotency_key:)
116
+ url = refund_ach_with_plaid_url(id: id)
117
+ Connection.instance.post(url, body, { 'idempotency-key': idempotency_key })
118
+ end
119
+
120
+ # @param [UUID] id
121
+ def refund_url(id:)
122
+ "/v1/subscriptions/#{id}/refund"
123
+ end
124
+
125
+ # @param [UUID] id
126
+ # @param [Hash] body
127
+ # @param [UUID] idempotency_key
128
+ def refund(id:, body:, idempotency_key:)
129
+ url = refund_url(id: id)
130
+ Connection.instance.post(url, body, { 'idempotency-key': idempotency_key })
131
+ end
132
+
133
+ # @param [Hash] params argument expects to have the following keys:
134
+ # [String] sort: asc / desc
135
+ # [Integer] limit
136
+ # [Integer] offset
137
+ # [String] start_date (format: yyyy-mm-dd)
138
+ # [String] end_date (format: yyyy-mm-dd)
139
+ # [Boolean] reveal_bank_info
140
+ # [String] include (example: {include: 'ach_transfers'})
141
+ # @param [Hash] body: expects to have "ids" key
142
+ def find_all(params: {}, body: {})
143
+ query = '?'
144
+ query += URI.encode_www_form(params)
145
+ Connection.instance.post("#{URL}#{query}", body)
146
+ end
147
+
148
+ def url(id)
149
+ "#{URL}/#{id}/finalize"
150
+ end
151
+
152
+ # @param
153
+ # 'id' [String] id of subscriber
154
+ # @param
155
+ # body [Hash] argument expects to have the following keys:
156
+ # document_signer: { "name": [String], "title": [String] }
157
+ # "name" The name of the signer.
158
+ # "title" The title of the signer as relates to the entity it represents.
159
+ #
160
+ # Finalize a subscription to be ready to create a bank account.
161
+ def finalize(id:, body:)
162
+ url = url id
163
+ Connection.instance.post(url, body)
164
+ end
165
+ end
166
+ end
167
+ end
@@ -0,0 +1,39 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Sydecar
4
+ class Vendor
5
+ URL = '/v1/vendors'
6
+ CREATE_URL = "#{URL}/create"
7
+
8
+ class << self
9
+ # @param [Hash] body
10
+ def create(body:)
11
+ Connection.instance.post(CREATE_URL, body)
12
+ end
13
+
14
+ # @param [UUID] id
15
+ def find(id:)
16
+ Connection.instance.get("#{URL}/#{id}", { reveal_pii: true })
17
+ end
18
+
19
+ # @param [UUID] id
20
+ # @param [Hash] body
21
+ def update(id:, body:)
22
+ Connection.instance.patch("#{URL}/#{id}", body)
23
+ end
24
+
25
+ # @param [Hash] params argument expects to have the following keys
26
+ # [String] sort: asc / desc
27
+ # [Integer] limit
28
+ # [Integer] offset
29
+ # [String] start_date (format: yyyy-mm-dd)
30
+ # [String] end_date (format: yyyy-mm-dd)
31
+ # @param [Hash] body: expects to have "ids" key
32
+ def find_all(params: {}, body: {})
33
+ query = '?'
34
+ query += URI.encode_www_form(params)
35
+ Connection.instance.post("#{URL}#{query}", body)
36
+ end
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Sydecar
4
+ VERSION = '0.1.6'
5
+ end
@@ -0,0 +1,194 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Sydecar
4
+ class WebhookCalls
5
+ URL = '/v1/configure/webhooks'
6
+ class << self
7
+ # The method create a webhook callback URL
8
+ # @param
9
+ # HEADER PARAMETERS:
10
+ # - idempotency-key [String] - Idempotency key header for sensitive operations
11
+ # REQUEST BODY SCHEMA: application/json
12
+ # - url [String] - The callback url associated the the webhook (required)
13
+ # - label [String] - A label to easily identify your web hook (required)
14
+ # - token [String] - For security reasons every webhook is associated with a token. (required)
15
+ # This token will be used to sign the incoming payloads.
16
+ # - disabled [boolean] - Enable / disable your web hook. (required)
17
+ #
18
+ # @note
19
+ # Set a webhook callback URL. You can provide any URL for Sydecar webhook callbacks to land.
20
+ # All webhook callbacks for the specified environment will be directed to the URL you provide.
21
+ # For maximum security, make sure to use https endpoints. In addition, webhook calls will be signed with a token.
22
+ #
23
+ # @example
24
+ # Response samples:
25
+ # {
26
+ # "id": "string",
27
+ # "created_at": "2019-08-24T14:15:22Z",
28
+ # "updated_at": "2019-08-24T14:15:22Z",
29
+ # "url": "string",
30
+ # "label": "string",
31
+ # "token": "string",
32
+ # "disabled": true
33
+ # }
34
+ # @return [Hash] - Responses: > '201'
35
+ #
36
+ # See on the https://api-docs.sydecar.io/api/#tag/Configuration/operation/createWebhook
37
+ def create(body:, idempotency_key:)
38
+ Connection.instance.post("#{URL}/create", body, { 'idempotency-key': idempotency_key })
39
+ end
40
+
41
+ # This method fetch all webhooks
42
+ # Retrieve all webhooks created to date (filtered). Pagination is available.
43
+ # @param
44
+ # Query parameters [Hash]
45
+ # - 'sort' [String] (Enum: 'asc', 'desc')
46
+ # - 'limit' [Number] (<=100)
47
+ # - 'offset' [Number]
48
+ # - 'start_date' [String]
49
+ # - 'end_date' [String]
50
+ # @example
51
+ # RESPONSE DATA (Sample):
52
+ # {
53
+ # "data": [
54
+ # {
55
+ # "id": "string",
56
+ # "created_at": "2019-08-24T14:15:22Z",
57
+ # "updated_at": "2019-08-24T14:15:22Z",
58
+ # "url": "string",
59
+ # "label": "string",
60
+ # "token": "string",
61
+ # "disabled": true
62
+ # }
63
+ # ],
64
+ # "pagination": {
65
+ # "limit": 0,
66
+ # "offset": 0,
67
+ # "total": 0
68
+ # }
69
+ # }
70
+ # @return See example RESPONSES: > '200'
71
+ #
72
+ # See on the https://api-docs.sydecar.io/api/#tag/Configuration/operation/getAllWebhooks
73
+ def find_all(query: {})
74
+ query = "?#{URI.encode_www_form(query)}"
75
+ Connection.instance.post("#{URL}#{query}")
76
+ end
77
+
78
+ # This method Fetch webhook information by id
79
+ # Fetch webhook information by id. This does not include the associate webhook events.
80
+ # @param
81
+ # PATH PARAMETERS
82
+ # - webhook_id [String] (required)
83
+ # Response samples
84
+ # {
85
+ # "id": "string",
86
+ # "created_at": "2019-08-24T14:15:22Z",
87
+ # "updated_at": "2019-08-24T14:15:22Z",
88
+ # "url": "string",
89
+ # "label": "string",
90
+ # "token": "string",
91
+ # "disabled": true
92
+ # }
93
+ # return [Hash] Responses: > '200'
94
+ #
95
+ # See on the https://api-docs.sydecar.io/api/#tag/Configuration/operation/getWebhook
96
+ def find(id:)
97
+ Connection.instance.get("#{URL}/#{id}")
98
+ end
99
+
100
+ # This method Update a webhook
101
+ # Update a webhook. You can update the label, url and/or token.
102
+ # @param
103
+ # PATH PARAMETERS
104
+ # - webhook_id [String] (required)
105
+ # REQUEST BODY SCHEMA: application/json
106
+ # - url [String] - The callback url associated the the webhook (required)
107
+ # - label [String] - A label to easily identify your web hook (required)
108
+ # - token [String] - For security reasons every webhook is associated with a token. (required)
109
+ # This token will be used to sign the incoming payloads.
110
+ # - disabled [boolean] - Enable / disable your web hook. (required)
111
+ # @example
112
+ # Response samples:
113
+ # {
114
+ # "id": "string",
115
+ # "created_at": "2019-08-24T14:15:22Z",
116
+ # "updated_at": "2019-08-24T14:15:22Z",
117
+ # "url": "string",
118
+ # "label": "string",
119
+ # "token": "string",
120
+ # "disabled": true
121
+ # }
122
+ # @return [Hash] - Responses: > '200'
123
+ #
124
+ # See on the https://api-docs.sydecar.io/api/#tag/Configuration/operation/updateWebhook
125
+ def update(id:, body:)
126
+ Connection.instance.patch("#{URL}/#{id}", body)
127
+ end
128
+
129
+ # This method Fetch latest webhook events
130
+ # Fetch the latest events for a webhook.
131
+ # @param
132
+ # PATH PARAMETERS
133
+ # - webhook_id [String] (required)
134
+ # Query parameters [Hash]
135
+ # - 'sort' [String] (Enum: 'asc', 'desc')
136
+ # - 'limit' [Number] (<=100)
137
+ # - 'offset' [Number]
138
+ # - 'start_date' [String]
139
+ # - 'end_date' [String]
140
+ # @example
141
+ # RESPONSE DATA (Sample):
142
+ # {
143
+ # "data": [
144
+ # {
145
+ # "id": "string",
146
+ # "created_at": "2019-08-24T14:15:22Z",
147
+ # "updated_at": "2019-08-24T14:15:22Z",
148
+ # "type": "plaid.account.item.expiring",
149
+ # "details": {
150
+ # "property1": "string",
151
+ # "property2": "string"
152
+ # }
153
+ # }
154
+ # ],
155
+ # "pagination": {
156
+ # "limit": 0,
157
+ # "offset": 0,
158
+ # "total": 0
159
+ # }
160
+ # }
161
+ # @return See example RESPONSES: > '200'
162
+ #
163
+ # See on the https://api-docs.sydecar.io/api/#tag/Configuration/operation/getAllWebhookEvents
164
+ def find_latest_events(id:, query: {})
165
+ query = URI.encode_www_form(query)
166
+ Connection.instance.post("#{URL}/#{id}/events?#{query}")
167
+ end
168
+
169
+ # This method Resend webhook event
170
+ # Resend a webhook event which was previously published.
171
+ # @param
172
+ # PATH PARAMETERS
173
+ # - event_id [String] (required)
174
+ # @example
175
+ # Response samples
176
+ # {
177
+ # "id": "string",
178
+ # "created_at": "2019-08-24T14:15:22Z",
179
+ # "updated_at": "2019-08-24T14:15:22Z",
180
+ # "type": "plaid.account.item.expiring",
181
+ # "details": {
182
+ # "property1": "string",
183
+ # "property2": "string"
184
+ # }
185
+ # }
186
+ # @return [Hash] Responses > '200'
187
+ #
188
+ # See on the https://api-docs.sydecar.io/api/#tag/Configuration/operation/replayWebhookEvent
189
+ def resend_event(event_id:)
190
+ Connection.instance.post("#{URL}/event/#{event_id}")
191
+ end
192
+ end
193
+ end
194
+ end
data/lib/sydecar.rb ADDED
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'bundler/setup'
4
+ Bundler.require(:default)
5
+ require 'uri'
6
+
7
+ require_relative "sydecar/version"
8
+ require_relative "sydecar/constants"
9
+ require_relative "sydecar/base_connection"
10
+ require_relative "sydecar/connection"
11
+ require_relative "sydecar/file_connection"
12
+ require_relative "sydecar/person"
13
+ require_relative "sydecar/profile"
14
+ require_relative "sydecar/profile/entity"
15
+ require_relative "sydecar/profile/individual"
16
+ require_relative "sydecar/entity"
17
+ require_relative "sydecar/bank_account"
18
+ require_relative "sydecar/spv"
19
+ require_relative "sydecar/vendor"
20
+ require_relative "sydecar/expense"
21
+ require_relative "sydecar/subscription"
22
+ require_relative "sydecar/document"
23
+ require_relative "sydecar/plaid"
24
+ require_relative "sydecar/webhook_calls"
25
+ require_relative "sydecar/capital_call"
26
+
27
+ module Sydecar
28
+ class TokenNotSetError < StandardError; end
29
+ class BaseUrlNotSetError < StandardError; end
30
+ # Your code goes here...
31
+ end
metadata ADDED
@@ -0,0 +1,174 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: sydecar
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.6
5
+ platform: ruby
6
+ authors:
7
+ - 1lyan
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2023-09-05 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: webmock
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '3.18'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '3.18'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rspec
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '3.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '3.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: byebug
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '11.1'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '11.1'
55
+ - !ruby/object:Gem::Dependency
56
+ name: awesome_print
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '1.9'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '1.9'
69
+ - !ruby/object:Gem::Dependency
70
+ name: faraday
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '2.7'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '2.7'
83
+ - !ruby/object:Gem::Dependency
84
+ name: json
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '2.6'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '2.6'
97
+ - !ruby/object:Gem::Dependency
98
+ name: faraday-multipart
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '1.0'
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '1.0'
111
+ description: Ruby bindings for the Sydecar API.
112
+ email:
113
+ - ilya.nechiporenko@gmail.com
114
+ executables: []
115
+ extensions: []
116
+ extra_rdoc_files: []
117
+ files:
118
+ - ".rspec"
119
+ - ".ruby-gemset"
120
+ - ".ruby-version"
121
+ - CHANGELOG.md
122
+ - Gemfile
123
+ - Gemfile.lock
124
+ - LICENSE.txt
125
+ - README.md
126
+ - Rakefile
127
+ - lib/sydecar.rb
128
+ - lib/sydecar/bank_account.rb
129
+ - lib/sydecar/base_connection.rb
130
+ - lib/sydecar/capital_call.rb
131
+ - lib/sydecar/connection.rb
132
+ - lib/sydecar/constants.rb
133
+ - lib/sydecar/document.rb
134
+ - lib/sydecar/entity.rb
135
+ - lib/sydecar/expense.rb
136
+ - lib/sydecar/file_connection.rb
137
+ - lib/sydecar/person.rb
138
+ - lib/sydecar/plaid.rb
139
+ - lib/sydecar/profile.rb
140
+ - lib/sydecar/profile/entity.rb
141
+ - lib/sydecar/profile/individual.rb
142
+ - lib/sydecar/spv.rb
143
+ - lib/sydecar/subscription.rb
144
+ - lib/sydecar/vendor.rb
145
+ - lib/sydecar/version.rb
146
+ - lib/sydecar/webhook_calls.rb
147
+ homepage: https://github.com/Play-Money/sydecar.
148
+ licenses:
149
+ - MIT
150
+ metadata:
151
+ allowed_push_host: https://rubygems.org
152
+ homepage_uri: https://github.com/Play-Money/sydecar.
153
+ source_code_uri: https://github.com/Play-Money/sydecar.
154
+ changelog_uri: https://github.com/Play-Money/sydecar.
155
+ post_install_message:
156
+ rdoc_options: []
157
+ require_paths:
158
+ - lib
159
+ required_ruby_version: !ruby/object:Gem::Requirement
160
+ requirements:
161
+ - - ">="
162
+ - !ruby/object:Gem::Version
163
+ version: 2.6.0
164
+ required_rubygems_version: !ruby/object:Gem::Requirement
165
+ requirements:
166
+ - - ">="
167
+ - !ruby/object:Gem::Version
168
+ version: '0'
169
+ requirements: []
170
+ rubygems_version: 3.3.7
171
+ signing_key:
172
+ specification_version: 4
173
+ summary: Ruby bindings for the Sydecar API.
174
+ test_files: []