plaid 4.1.0 → 5.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,48 +1,118 @@
1
1
  module Plaid
2
- # Public: Class used to call the BankAccountToken sub-product.
3
- class BankAccountToken
4
- def initialize(client)
5
- @client = client
6
- end
2
+ # Public: Class used to call the Stripe sub-product.
3
+ class Stripe < BaseProduct
4
+ # Public: Class used to call the BankAccountToken sub-product.
5
+ class BankAccountToken < BaseProduct
6
+ # Public: Creates a Stripe bank account token from an access_token.
7
+ #
8
+ # Does a POST /processor/stripe/bank_account_token/create call which can
9
+ # be used to generate a Stripe bank account token for a given account
10
+ # ID.
11
+ #
12
+ # access_token - access_token to create a public token for
13
+ # account_id - ID of the account to create a bank account token for
14
+ #
15
+ # Returns CreateResponse object containing a Stripe bank account token.
16
+ def create(access_token, account_id)
17
+ post_with_auth 'processor/stripe/bank_account_token/create',
18
+ CreateResponse,
19
+ access_token: access_token, account_id: account_id
20
+ end
7
21
 
8
- # Public: Creates a Stripe bank account token from an access_token.
9
- #
10
- # Does a POST /processor/stripe/bank_account_token/create call which can
11
- # be used to generate a Stripe bank account token for a given account ID.
12
- #
13
- # access_token - access_token to create a public token for
14
- # account_id - ID of the account to create a bank account token for
15
- #
16
- # Returns a parsed JSON containing a Stripe bank account token
17
- def create(access_token, account_id)
18
- payload = { access_token: access_token,
19
- account_id: account_id }
20
- @client.post_with_auth('processor/stripe/bank_account_token/create',
21
- payload)
22
+ # Public: A response for /processor/stripe/bank_account_token/create.
23
+ class CreateResponse < Models::BaseResponse
24
+ ##
25
+ # :attr_reader:
26
+ # Public: The String stripe token.
27
+ property :stripe_bank_account_token
28
+ end
22
29
  end
30
+
31
+ ##
32
+ # :attr_reader:
33
+ # Public: The Plaid::Stripe::BankAccountToken product accessor.
34
+ subproduct :bank_account_token, BankAccountToken
23
35
  end
24
36
 
25
- # Public: Class used to call the Stripe sub-product.
26
- class Stripe
27
- # Public: Memoized class instance to make requests from Plaid::BankAccountToken
28
- def bank_account_token
29
- @bank_account_token ||= Plaid::BankAccountToken.new(@client)
37
+ # Public: A response for /processor/.../processor_token/create.
38
+ class ProcessorTokenResponse < Models::BaseResponse
39
+ ##
40
+ # :attr_reader:
41
+ # Public: The String processor token.
42
+ property :processor_token
43
+ end
44
+
45
+ # Public: Class used to call the Dwolla sub-product.
46
+ class Dwolla < BaseProduct
47
+ # Public: Class used to call the dwolla.processor_token subproduct
48
+ class ProcessorToken < BaseProduct
49
+ # Public: Creates a Dwolla processor token from an access_token.
50
+ #
51
+ # Does a POST /processor/dwolla/processor_token/create call which can be
52
+ # used to generate a Dwolla processor token for a given account ID.
53
+ #
54
+ # access_token - access_token to create a public token for.
55
+ # account_id - ID of the account to create a processor token for.
56
+ #
57
+ # Returns a ProcessorTokenResponse object containing a Dwolla processor
58
+ # token.
59
+ def create(access_token, account_id)
60
+ post_with_auth 'processor/dwolla/processor_token/create',
61
+ ProcessorTokenResponse,
62
+ access_token: access_token,
63
+ account_id: account_id
64
+ end
30
65
  end
31
66
 
32
- def initialize(client)
33
- @client = client
67
+ ##
68
+ # :attr_reader:
69
+ # Public: The Plaid::Dwolla::ProcessorToken product accessor.
70
+ subproduct :processor_token, ProcessorToken
71
+ end
72
+
73
+ # Public: Class used to call the Apex sub-product.
74
+ class Apex < BaseProduct
75
+ # Public: Class used to call the apex.processor_token subproduct
76
+ class ProcessorToken < BaseProduct
77
+ # Public: Creates an Apex processor token from an access_token.
78
+ #
79
+ # Does a POST /processor/apex/processor_token/create call which can be
80
+ # used to generate an Apex processor token for a given account ID.
81
+ #
82
+ # access_token - access_token to create a public token for.
83
+ # account_id - ID of the account to create a processor token for.
84
+ #
85
+ # Returns a ProcessorTokenResponse object containing an Apex processor
86
+ # token.
87
+ def create(access_token, account_id)
88
+ post_with_auth 'processor/apex/processor_token/create',
89
+ ProcessorTokenResponse,
90
+ access_token: access_token,
91
+ account_id: account_id
92
+ end
34
93
  end
94
+
95
+ ##
96
+ # :attr_reader:
97
+ # Public: The Plaid::ApexProcessorToken product accessor.
98
+ subproduct :processor_token, ProcessorToken
35
99
  end
36
100
 
37
101
  # Public: Class used to call the Processor product.
38
- class Processor
39
- # Public: Memoized class instance to make requests from Plaid::Stripe
40
- def stripe
41
- @stripe ||= Plaid::Stripe.new(@client)
42
- end
102
+ class Processor < BaseProduct
103
+ ##
104
+ # :attr_reader:
105
+ # Public: The Plaid::Stripe product accessor.
106
+ subproduct :stripe
43
107
 
44
- def initialize(client)
45
- @client = client
46
- end
108
+ ##
109
+ # :attr_reader:
110
+ # Public: The Plaid::Dwolla product accessor.
111
+ subproduct :dwolla
112
+
113
+ ##
114
+ # :attr_reader:
115
+ # Public: The Plaid::Apex product accessor.
116
+ subproduct :apex
47
117
  end
48
118
  end
@@ -1,32 +1,33 @@
1
1
  module Plaid
2
2
  # Public: Class used to call the SandboxItem sub-product.
3
- class SandboxItem
4
- def initialize(client)
5
- @client = client
6
- end
7
-
8
- # Public: Resets sandbox item login
3
+ class SandboxItem < BaseProduct
4
+ # Public: Resets sandbox item login.
9
5
  #
10
- # Does a POST /sandbox/item/reset_login call
6
+ # Does a POST /sandbox/item/reset_login call.
11
7
  #
12
- # access_token - access_token who's item to reset login for
8
+ # access_token - access_token which item to reset login for.
13
9
  #
14
- # Returns a parsed JSON of response
10
+ # Returns a ResetLoginResponse object.
15
11
  def reset_login(access_token)
16
- payload = { access_token: access_token }
17
- @client.post_with_auth('sandbox/item/reset_login', payload)
12
+ post_with_auth 'sandbox/item/reset_login',
13
+ ResetLoginResponse,
14
+ access_token: access_token
18
15
  end
19
- end
20
16
 
21
- # Public: Class used to call the Sandbox product.
22
- class Sandbox
23
- # Public: Memoized class instance to make requests from Plaid::SandboxItem
24
- def sandbox_item
25
- @sandbox_item ||= Plaid::SandboxItem.new(@client)
17
+ # Public: Response for /sandbox/item/reset_login.
18
+ class ResetLoginResponse < Models::BaseResponse
19
+ ##
20
+ # :attr_reader:
21
+ # Public: The Boolean reset success flag.
22
+ property :reset_login
26
23
  end
24
+ end
27
25
 
28
- def initialize(client)
29
- @client = client
30
- end
26
+ # Public: Class used to call the Sandbox product.
27
+ class Sandbox < BaseProduct
28
+ ##
29
+ # :attr_reader:
30
+ # Public: The Plaid::SandboxItem product accessor.
31
+ subproduct :sandbox_item
31
32
  end
32
33
  end
@@ -1,61 +1,66 @@
1
1
  require 'date'
2
2
 
3
3
  module Plaid
4
- # Internal: Converts date objects to strings if needed
5
- #
6
- # Takes in a string or a Date object and performs necessary operations to return a
7
- # string representation of the Date
8
- #
9
- # date - Date in Date object form or string form (YYYY-MM-DD)
10
- #
11
- # Returns a string representing a date needed for transaction start and end dates
12
- def self.convert_to_date_string(date)
13
- case date
14
- when String
15
- date
16
- else
17
- date.to_date.strftime('%Y-%m-%d')
18
- end
19
- end
20
-
21
4
  # Public: Class used to call the Transactions product.
22
- class Transactions
23
- def initialize(client)
24
- @client = client
25
- end
26
-
5
+ class Transactions < BaseProduct
27
6
  # Public: Get information about transactions
28
7
  #
29
- # Does a POST /transactions/get call which gives you high level account data along
30
- # with transactions from all accounts contained in the access_token's item
8
+ # Does a POST /transactions/get call which gives you high level account
9
+ # data along with transactions from all accounts contained in the
10
+ # access_token's item.
31
11
  #
32
- # access_token - access_token who's item to fetch transactions for
33
- # start_date - Start of query for transactions
34
- # end_date - End of query for transactions
35
- # account_ids - Specific account ids to fetch balances for (optional)
36
- # count - Amount of transactions to pull (optional)
37
- # offset - Offset to start pulling transactions (optional)
38
- # options - Additional options to merge into API request
12
+ # access_token - access_token who's item to fetch transactions for.
13
+ # start_date - Start of query for transactions.
14
+ # end_date - End of query for transactions.
15
+ # account_ids - Specific account ids to fetch balances for (optional).
16
+ # count - Amount of transactions to pull (optional).
17
+ # offset - Offset to start pulling transactions (optional).
18
+ # options - Additional options to merge into API request.
39
19
  #
40
- # Returns a parsed JSON listing information on transactions
41
- def get(access_token,
42
- start_date,
43
- end_date,
44
- account_ids: nil,
45
- count: nil,
46
- offset: nil,
47
- options: nil)
20
+ # Returns GetResponse.
21
+ def get(access_token, start_date, end_date,
22
+ account_ids: nil, count: nil, offset: nil, options: nil)
23
+
48
24
  options_payload = {}
49
25
  options_payload[:account_ids] = account_ids unless account_ids.nil?
50
26
  options_payload[:count] = count unless count.nil?
51
27
  options_payload[:offset] = offset unless offset.nil?
52
- options_payload = options_payload.merge(options) unless options.nil?
28
+ options_payload.merge!(options) unless options.nil?
29
+
30
+ post_with_auth 'transactions/get',
31
+ GetResponse,
32
+ access_token: access_token,
33
+ start_date: Plaid.convert_to_date_string(start_date),
34
+ end_date: Plaid.convert_to_date_string(end_date),
35
+ options: options_payload
36
+ end
37
+
38
+ # Public: Response for /transactions/get.
39
+ class GetResponse < Models::BaseResponse
40
+ ##
41
+ # :attr_reader:
42
+ # Public: The item: Plaid::Models::Item.
43
+ property :item, coerce: Models::Item
44
+
45
+ ##
46
+ # :attr_reader:
47
+ # Public: The list of accounts: Array of Plaid::Models::Account.
48
+ property :accounts, coerce: Array[Models::Account]
49
+
50
+ ##
51
+ # :attr_reader:
52
+ # Public: The list of transactions: Array of Plaid::Models::Transaction.
53
+ property :transactions, coerce: Array[Models::Transaction]
54
+
55
+ ##
56
+ # :attr_reader:
57
+ # Public: The String last updated time (if available).
58
+ property :last_updated
53
59
 
54
- payload = { access_token: access_token,
55
- start_date: Plaid.convert_to_date_string(start_date),
56
- end_date: Plaid.convert_to_date_string(end_date),
57
- options: options_payload }
58
- @client.post_with_auth('transactions/get', payload)
60
+ ##
61
+ # :attr_reader:
62
+ # Public: The Numeric total transactions count.
63
+ property :total_transactions
59
64
  end
60
65
  end
61
66
  end
@@ -1,3 +1,3 @@
1
1
  module Plaid
2
- VERSION = '4.1.0'.freeze
2
+ VERSION = '5.0.0'.freeze
3
3
  end
@@ -1,9 +1,8 @@
1
- # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
1
+ lib = File.expand_path('lib', __dir__)
3
2
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
3
  require 'plaid/version'
5
4
 
6
- Gem::Specification.new do |spec|
5
+ Gem::Specification.new do |spec| # rubocop:disable Metrics/BlockLength
7
6
  spec.name = 'plaid'
8
7
  spec.version = Plaid::VERSION
9
8
  spec.authors = ['Edmund Loo']
@@ -15,8 +14,9 @@ Gem::Specification.new do |spec|
15
14
  spec.homepage = 'https://plaid.com/'
16
15
  spec.license = 'MIT'
17
16
 
18
- # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
19
- # to allow pushing to a single host or delete this section to allow pushing to any host.
17
+ # Prevent pushing this gem to RubyGems.org. To allow pushes either set the
18
+ # 'allowed_push_host' to allow pushing to a single host or delete this
19
+ # section to allow pushing to any host.
20
20
  if spec.respond_to?(:metadata)
21
21
  spec.metadata['allowed_push_host'] = 'https://rubygems.org'
22
22
  else
@@ -36,12 +36,14 @@ Gem::Specification.new do |spec|
36
36
 
37
37
  spec.add_dependency 'faraday'
38
38
  spec.add_dependency 'faraday_middleware'
39
+ spec.add_dependency 'hashie', '>= 3.4.3'
39
40
 
40
41
  spec.add_development_dependency 'bundler', '~> 1.7'
41
42
  spec.add_development_dependency 'dotenv'
42
- spec.add_development_dependency 'rake', '>= 10.0'
43
- spec.add_development_dependency 'sdoc', '~> 0.4.1'
44
43
  spec.add_development_dependency 'minitest', '~> 5.10'
45
44
  spec.add_development_dependency 'minitest-around', '~> 0.4.0'
46
- spec.add_development_dependency 'vcr', '~> 3.0.3'
45
+ spec.add_development_dependency 'rake', '>= 10.0'
46
+ spec.add_development_dependency 'rubocop', '~> 0.53.0'
47
+ spec.add_development_dependency 'sdoc', '~> 1.0.0'
48
+ spec.add_development_dependency 'vcr', '~> 4.0.0'
47
49
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: plaid
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.1.0
4
+ version: 5.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Edmund Loo
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-01-04 00:00:00.000000000 Z
11
+ date: 2018-03-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -38,6 +38,20 @@ dependencies:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: hashie
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: 3.4.3
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: 3.4.3
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: bundler
43
57
  requirement: !ruby/object:Gem::Requirement
@@ -67,75 +81,89 @@ dependencies:
67
81
  - !ruby/object:Gem::Version
68
82
  version: '0'
69
83
  - !ruby/object:Gem::Dependency
70
- name: rake
84
+ name: minitest
71
85
  requirement: !ruby/object:Gem::Requirement
72
86
  requirements:
73
- - - ">="
87
+ - - "~>"
74
88
  - !ruby/object:Gem::Version
75
- version: '10.0'
89
+ version: '5.10'
76
90
  type: :development
77
91
  prerelease: false
78
92
  version_requirements: !ruby/object:Gem::Requirement
79
93
  requirements:
80
- - - ">="
94
+ - - "~>"
81
95
  - !ruby/object:Gem::Version
82
- version: '10.0'
96
+ version: '5.10'
83
97
  - !ruby/object:Gem::Dependency
84
- name: sdoc
98
+ name: minitest-around
85
99
  requirement: !ruby/object:Gem::Requirement
86
100
  requirements:
87
101
  - - "~>"
88
102
  - !ruby/object:Gem::Version
89
- version: 0.4.1
103
+ version: 0.4.0
90
104
  type: :development
91
105
  prerelease: false
92
106
  version_requirements: !ruby/object:Gem::Requirement
93
107
  requirements:
94
108
  - - "~>"
95
109
  - !ruby/object:Gem::Version
96
- version: 0.4.1
110
+ version: 0.4.0
97
111
  - !ruby/object:Gem::Dependency
98
- name: minitest
112
+ name: rake
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '10.0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '10.0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: rubocop
99
127
  requirement: !ruby/object:Gem::Requirement
100
128
  requirements:
101
129
  - - "~>"
102
130
  - !ruby/object:Gem::Version
103
- version: '5.10'
131
+ version: 0.53.0
104
132
  type: :development
105
133
  prerelease: false
106
134
  version_requirements: !ruby/object:Gem::Requirement
107
135
  requirements:
108
136
  - - "~>"
109
137
  - !ruby/object:Gem::Version
110
- version: '5.10'
138
+ version: 0.53.0
111
139
  - !ruby/object:Gem::Dependency
112
- name: minitest-around
140
+ name: sdoc
113
141
  requirement: !ruby/object:Gem::Requirement
114
142
  requirements:
115
143
  - - "~>"
116
144
  - !ruby/object:Gem::Version
117
- version: 0.4.0
145
+ version: 1.0.0
118
146
  type: :development
119
147
  prerelease: false
120
148
  version_requirements: !ruby/object:Gem::Requirement
121
149
  requirements:
122
150
  - - "~>"
123
151
  - !ruby/object:Gem::Version
124
- version: 0.4.0
152
+ version: 1.0.0
125
153
  - !ruby/object:Gem::Dependency
126
154
  name: vcr
127
155
  requirement: !ruby/object:Gem::Requirement
128
156
  requirements:
129
157
  - - "~>"
130
158
  - !ruby/object:Gem::Version
131
- version: 3.0.3
159
+ version: 4.0.0
132
160
  type: :development
133
161
  prerelease: false
134
162
  version_requirements: !ruby/object:Gem::Requirement
135
163
  requirements:
136
164
  - - "~>"
137
165
  - !ruby/object:Gem::Version
138
- version: 3.0.3
166
+ version: 4.0.0
139
167
  description: Ruby gem wrapper for the Plaid API. Read more at the homepage, the wiki,
140
168
  or in the Plaid documentation.
141
169
  email:
@@ -144,10 +172,13 @@ executables: []
144
172
  extensions: []
145
173
  extra_rdoc_files: []
146
174
  files:
175
+ - ".circleci/config.yml"
147
176
  - ".env.sample"
177
+ - ".rubocop.yml"
148
178
  - CHANGELOG.md
149
179
  - CONTRIBUTING.md
150
180
  - Gemfile
181
+ - Gemfile.lock
151
182
  - LICENSE.txt
152
183
  - PUBLISHING.md
153
184
  - README.md
@@ -155,13 +186,14 @@ files:
155
186
  - UPGRADING.md
156
187
  - bin/console
157
188
  - bin/setup
158
- - circle.yml
159
189
  - lib/plaid.rb
160
190
  - lib/plaid/client.rb
161
191
  - lib/plaid/errors.rb
162
192
  - lib/plaid/middleware.rb
193
+ - lib/plaid/models.rb
163
194
  - lib/plaid/products/accounts.rb
164
195
  - lib/plaid/products/auth.rb
196
+ - lib/plaid/products/base_product.rb
165
197
  - lib/plaid/products/categories.rb
166
198
  - lib/plaid/products/credit_details.rb
167
199
  - lib/plaid/products/identity.rb