plaid 3.0.0 → 4.0.0
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.
- checksums.yaml +4 -4
- data/CONTRIBUTING.md +7 -1
- data/Gemfile +0 -1
- data/LICENSE.txt +21 -0
- data/README.md +233 -206
- data/Rakefile +1 -2
- data/bin/console +8 -7
- data/circle.yml +3 -0
- data/lib/plaid.rb +15 -60
- data/lib/plaid/client.rb +120 -52
- data/lib/plaid/connect.rb +75 -0
- data/lib/plaid/errors.rb +60 -24
- data/lib/plaid/products/accounts.rb +60 -0
- data/lib/plaid/products/auth.rb +29 -0
- data/lib/plaid/products/categories.rb +18 -0
- data/lib/plaid/products/credit_details.rb +21 -0
- data/lib/plaid/products/identity.rb +20 -0
- data/lib/plaid/products/income.rb +20 -0
- data/lib/plaid/products/institutions.rb +51 -0
- data/lib/plaid/products/item.rb +230 -0
- data/lib/plaid/products/processor.rb +48 -0
- data/lib/plaid/products/sandbox.rb +32 -0
- data/lib/plaid/products/transactions.rb +74 -0
- data/lib/plaid/version.rb +1 -1
- data/plaid.gemspec +13 -8
- metadata +21 -61
- data/CHANGELOG.md +0 -34
- data/LICENSE +0 -20
- data/UPGRADING.md +0 -60
- data/lib/plaid/account.rb +0 -144
- data/lib/plaid/category.rb +0 -62
- data/lib/plaid/connector.rb +0 -172
- data/lib/plaid/income.rb +0 -106
- data/lib/plaid/info.rb +0 -65
- data/lib/plaid/institution.rb +0 -253
- data/lib/plaid/risk.rb +0 -34
- data/lib/plaid/transaction.rb +0 -128
- data/lib/plaid/user.rb +0 -507
- data/lib/plaid/webhook.rb +0 -153
data/lib/plaid/webhook.rb
DELETED
@@ -1,153 +0,0 @@
|
|
1
|
-
module Plaid
|
2
|
-
# Public: Representation of a webhook.
|
3
|
-
class Webhook
|
4
|
-
# Public: The String human readable explanation of this webhook request.
|
5
|
-
# E.g. "Initial transaction pull finished".
|
6
|
-
attr_reader :message
|
7
|
-
|
8
|
-
# Public: The String access token for authenticated user.
|
9
|
-
attr_reader :access_token
|
10
|
-
|
11
|
-
# Public: The Integer number of transactions available in Plaid.
|
12
|
-
# E.g. 124
|
13
|
-
attr_reader :total_transactions
|
14
|
-
|
15
|
-
# Public: The Integer code denoting the type of webhook this is. E.g. 0
|
16
|
-
attr_reader :code
|
17
|
-
|
18
|
-
# Public: Initialize a Webhook instance.
|
19
|
-
#
|
20
|
-
# fields - The Hash with fields.
|
21
|
-
def initialize(fields)
|
22
|
-
@message = fields['message']
|
23
|
-
@access_token = fields['access_token']
|
24
|
-
@total_transactions = fields['total_transactions']
|
25
|
-
@code = fields['code']
|
26
|
-
# present only for Removed Transaction Webhook
|
27
|
-
@removed_transactions = fields['removed_transactions']
|
28
|
-
# present only for Error Response Webhook
|
29
|
-
@resolve = fields['resolve']
|
30
|
-
end
|
31
|
-
|
32
|
-
# Public: Share the type of Webhook this is from its code
|
33
|
-
#
|
34
|
-
# Returns String webhook type
|
35
|
-
def type
|
36
|
-
Webhook::CODEX[code] || 'ERROR_RESPONSE'
|
37
|
-
end
|
38
|
-
|
39
|
-
# Public: Detect if the webhook is Initial Transaction Webhook. Occurs
|
40
|
-
# once the initial transaction pull has finished.
|
41
|
-
#
|
42
|
-
# Returns true if it is.
|
43
|
-
def initial_transaction?
|
44
|
-
code == Webhook::INITIAL_TRANSACTION
|
45
|
-
end
|
46
|
-
|
47
|
-
# Public: Detect if the webhook is Historical Transaction Webhook. Occurs
|
48
|
-
# once the historical transaction pull has completed, shortly after the
|
49
|
-
# initial transaction pull.
|
50
|
-
#
|
51
|
-
# Returns true if it is.
|
52
|
-
def historical_transaction?
|
53
|
-
code == Webhook::HISTORICAL_TRANSACTION
|
54
|
-
end
|
55
|
-
|
56
|
-
# Public: Detect if the webhook is Normal Transaction Webhook. Occurs at
|
57
|
-
# set intervals throughout the day as data is updated from the financial
|
58
|
-
# institutions.
|
59
|
-
#
|
60
|
-
# Returns true if it is.
|
61
|
-
def normal_transaction?
|
62
|
-
code == Webhook::NORMAL_TRANSACTION
|
63
|
-
end
|
64
|
-
|
65
|
-
# Public: Detect if the webhook is Removed Transaction Webhook. Occurs when
|
66
|
-
# transactions have been removed from our system.
|
67
|
-
#
|
68
|
-
# Returns true if it is.
|
69
|
-
def removed_transaction?
|
70
|
-
code == Webhook::REMOVED_TRANSACTION
|
71
|
-
end
|
72
|
-
|
73
|
-
# Public: Detect if the webhook is User's Webhook Updated. Occurs when an
|
74
|
-
# user's webhook is updated via a PATCH request without credentials.
|
75
|
-
#
|
76
|
-
# Returns true if it is.
|
77
|
-
def user_webhook_updated?
|
78
|
-
code == Webhook::USER_WEBHOOK_UPDATED
|
79
|
-
end
|
80
|
-
|
81
|
-
# Public: Detect if the webhook is Income. Occurs when Income data is ready.
|
82
|
-
#
|
83
|
-
# Returns true if it is.
|
84
|
-
def income?
|
85
|
-
code == Webhook::INCOME
|
86
|
-
end
|
87
|
-
|
88
|
-
# Public: Detect if the webhook is Risk. Occurs when Risk data is ready.
|
89
|
-
#
|
90
|
-
# Returns true if it is.
|
91
|
-
def risk?
|
92
|
-
code == Webhook::RISK
|
93
|
-
end
|
94
|
-
|
95
|
-
# Public: Detect if the webhook is Error Response Webhook. Triggered when
|
96
|
-
# an error has occurred. Includes the relevant Plaid error code with
|
97
|
-
# details on both the error type and steps for error resolution.
|
98
|
-
#
|
99
|
-
# Returns true if it is.
|
100
|
-
def error_response?
|
101
|
-
Webhook::CODEX[code].nil?
|
102
|
-
end
|
103
|
-
|
104
|
-
# Public: Get transaction IDs that were removed.
|
105
|
-
#
|
106
|
-
# Returns Array[String] or nil
|
107
|
-
def removed_transactions_ids
|
108
|
-
@removed_transactions
|
109
|
-
end
|
110
|
-
|
111
|
-
# Public: Get a Plaid::Error instance if this is an Error Response Webhook
|
112
|
-
#
|
113
|
-
# Returns Plaid::Error or nil
|
114
|
-
def error
|
115
|
-
if error_response?
|
116
|
-
Plaid::PlaidError.new @code, @message, @resolve
|
117
|
-
end
|
118
|
-
end
|
119
|
-
|
120
|
-
# Public: Get a String representation of the transaction.
|
121
|
-
#
|
122
|
-
# Returns a String.
|
123
|
-
def inspect
|
124
|
-
"#<Plaid::Webhook type=#{type.inspect} code=#{code.inspect}, access_token=#{access_token.inspect}, " \
|
125
|
-
"total_transactions=#{total_transactions.inspect}, message=#{message.inspect}>"
|
126
|
-
end
|
127
|
-
|
128
|
-
# Public: Get a String representation of the transaction.
|
129
|
-
#
|
130
|
-
# Returns a String.
|
131
|
-
alias to_s inspect
|
132
|
-
|
133
|
-
private
|
134
|
-
|
135
|
-
ERROR_RESPONSE = -1
|
136
|
-
|
137
|
-
codex = {}
|
138
|
-
{
|
139
|
-
'initial transaction' => 0,
|
140
|
-
'historical transaction' => 1,
|
141
|
-
'normal transaction' => 2,
|
142
|
-
'removed transaction' => 3,
|
143
|
-
'user webhook updated' => 4,
|
144
|
-
'income' => 10,
|
145
|
-
'risk' => 20
|
146
|
-
}.each do |event, idx|
|
147
|
-
name = event.split.map(&:upcase).join('_')
|
148
|
-
codex[idx] = name
|
149
|
-
const_set name, idx
|
150
|
-
end
|
151
|
-
CODEX = codex.freeze
|
152
|
-
end
|
153
|
-
end
|