trustev 0.3.2 → 0.4.0.pre.alpha
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +3 -329
- data/Rakefile +1 -2
- data/lib/trustev.rb +20 -68
- data/lib/trustev/{authenticate.rb → 1.2/authenticate.rb} +0 -0
- data/lib/trustev/{digital_signature.rb → 1.2/digital_signature.rb} +0 -0
- data/lib/trustev/{profile.rb → 1.2/profile.rb} +1 -1
- data/lib/trustev/{social.rb → 1.2/social.rb} +0 -0
- data/lib/trustev/{transaction.rb → 1.2/transaction.rb} +0 -0
- data/lib/trustev/1.2/trustev.rb +66 -0
- data/lib/trustev/2.0/address.rb +41 -0
- data/lib/trustev/2.0/authenticate.rb +40 -0
- data/lib/trustev/2.0/case.rb +45 -0
- data/lib/trustev/2.0/case_attribute.rb +24 -0
- data/lib/trustev/2.0/customer.rb +32 -0
- data/lib/trustev/2.0/customer_address.rb +5 -0
- data/lib/trustev/2.0/decision.rb +17 -0
- data/lib/trustev/2.0/email.rb +35 -0
- data/lib/trustev/2.0/item.rb +34 -0
- data/lib/trustev/2.0/payment.rb +33 -0
- data/lib/trustev/2.0/social.rb +38 -0
- data/lib/trustev/2.0/status.rb +34 -0
- data/lib/trustev/2.0/timestamp.rb +17 -0
- data/lib/trustev/2.0/transaction.rb +30 -0
- data/lib/trustev/2.0/transaction_address.rb +5 -0
- data/lib/trustev/2.0/trustev.rb +51 -0
- data/lib/trustev/error.rb +5 -6
- data/lib/trustev/version.rb +1 -1
- data/test/{authenticate_test.rb → 1.2/authenticate_test.rb} +0 -0
- data/test/{digital_signature_test.rb → 1.2/digital_signature_test.rb} +0 -0
- data/test/{error_test.rb → 1.2/error_test.rb} +3 -3
- data/test/{profile_test.rb → 1.2/profile_test.rb} +0 -0
- data/test/{social_test.rb → 1.2/social_test.rb} +0 -0
- data/test/{test_helper.rb → 1.2/test_helper.rb} +3 -2
- data/test/{transaction_test.rb → 1.2/transaction_test.rb} +0 -0
- data/test/2.0/authenticate_test.rb +13 -0
- data/test/2.0/case_test.rb +31 -0
- data/test/2.0/customer_address_test.rb +35 -0
- data/test/2.0/customer_test.rb +31 -0
- data/test/2.0/decision_test.rb +13 -0
- data/test/2.0/email_test.rb +33 -0
- data/test/2.0/error_test.rb +18 -0
- data/test/2.0/item_test.rb +33 -0
- data/test/2.0/payment_test.rb +33 -0
- data/test/2.0/social_test.rb +33 -0
- data/test/2.0/status_test.rb +27 -0
- data/test/2.0/test_helper.rb +165 -0
- data/test/2.0/transaction_address_Test.rb +35 -0
- data/test/2.0/transaction_test.rb +31 -0
- data/trustev.gemspec +3 -0
- metadata +111 -24
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7d80eedb1e622b67a06154a915d1afe37a2e8f23
|
4
|
+
data.tar.gz: 934015dc9d7fdbf540e65aa1d29113a9eb9a3876
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 87c4044fcaa0aa35377fd9e0af4ed11577ff1c28062ce984bb3523fa0200a50dadc19610dd68d714754ba6684572769bda171ae185abfeecb14dfa9c5eb92e27
|
7
|
+
data.tar.gz: 9383f68be6fd2a3e51239c24ee6ec8a29ee213b44ae5ab34c940058266a33b2a56d382c5521608ac82f8c8222fefdc146472bab975679809fa6bed2e771dc09e
|
data/README.md
CHANGED
@@ -5,337 +5,11 @@ Ruby wrapper for Trustev API
|
|
5
5
|
[![Gem Version](https://badge.fury.io/rb/trustev.svg)](http://badge.fury.io/rb/trustev)
|
6
6
|
![Codeship](https://codeship.com/projects/1e231930-5253-0132-d3ec-72279d09a1d7/status?branch=master)
|
7
7
|
|
8
|
-
|
8
|
+
# Documentation
|
9
9
|
|
10
|
-
|
10
|
+
See [the wiki](https://github.com/giftcardzen/trustev/wiki) for documentation.
|
11
11
|
|
12
|
-
|
13
|
-
gem 'trustev'
|
14
|
-
```
|
15
|
-
|
16
|
-
And then execute:
|
17
|
-
|
18
|
-
$ bundle
|
19
|
-
|
20
|
-
Or install it yourself as:
|
21
|
-
|
22
|
-
$ gem install trustev
|
23
|
-
|
24
|
-
## Configuration
|
25
|
-
Set the following options
|
26
|
-
```ruby
|
27
|
-
# This is your Trustev Site Username (NOTE: different from Reliance Login Username).
|
28
|
-
# It is available under the ‘View API Keys’ section of Reliance.
|
29
|
-
Trustev.username = 'username'
|
30
|
-
# This is your Trustev Site Password (NOTE: different from Reliance Login Password).
|
31
|
-
Trustev.password = 'password'
|
32
|
-
# This is your Trustev Site Shared Secret, available from Reliance.
|
33
|
-
Trustev.shared_secret = '0f0f0f0f'
|
34
|
-
#This is your Trustev Site Private Key, available from Reliance.
|
35
|
-
Trustev.private_key = 'ffffffff'
|
36
|
-
#This is your Trustev Site Public Key, available from Reliance.
|
37
|
-
# This parameter is OPTIONAL, but if you do NOT include it, `Trustev::DigitalSignature.valid?`
|
38
|
-
# will return FALSE if Trustev's servers are inaccessible
|
39
|
-
Trustev.public_key = 'f0f0f0f0'
|
40
|
-
```
|
41
|
-
|
42
|
-
## Usage
|
43
|
-
|
44
|
-
For more information on the parameters referenced below, see the [trustev API documentation](http://developers.trustev.com/#addtransaction)
|
45
|
-
|
46
|
-
### Authentication
|
47
|
-
|
48
|
-
Authentication is handled automatically. You never have to request an authentication token manually.
|
49
|
-
|
50
|
-
### Validation of Digital Signature
|
51
|
-
|
52
|
-
```ruby
|
53
|
-
# digital_signature = Trustev::DigitalSignature.new(digital_signature, timestamp, session_id, stage_1)
|
54
|
-
# digital_signature.valid?
|
55
|
-
# or
|
56
|
-
# digital_signature.invalid?
|
57
|
-
digital_signature = Trustev::DigitalSignature.new('ae5b0c9ea554fed8080457debed0cccf832c183b3fa7794b497f5492e98a74a2',
|
58
|
-
20141028163912,
|
59
|
-
'f39767e2-0cb5-hk97-a296-4619c269d59d',
|
60
|
-
'123456.joe@bloggs.com')
|
61
|
-
digital_signature.valid? # true
|
62
|
-
digital_signature.invalid? # false
|
63
|
-
```
|
64
|
-
|
65
|
-
### Transaction
|
66
|
-
|
67
|
-
#### Create a new transaction
|
68
|
-
|
69
|
-
Only the following fields are required:
|
70
|
-
* transaction_number
|
71
|
-
* transaction_data.currency
|
72
|
-
* transaction_data.total_transaction_value
|
73
|
-
* transaction_data.timestamp
|
74
|
-
* customer
|
75
|
-
```ruby
|
76
|
-
transaction = Trustev::Transaction.new('1234abcd')
|
77
|
-
transaction.create(
|
78
|
-
{
|
79
|
-
social_network: {
|
80
|
-
type: Trustev::SOCIAL_NETWORK_TYPES[:facebook],
|
81
|
-
id: '12345678'
|
82
|
-
},
|
83
|
-
transaction_data: {
|
84
|
-
currency_code: 'EUR',
|
85
|
-
total_delivery: 10.0,
|
86
|
-
total_before_tax: 40,
|
87
|
-
total_discount: 10,
|
88
|
-
total_tax: 10,
|
89
|
-
total_transaction_value: 50.00,
|
90
|
-
timestamp: 1391449224000,
|
91
|
-
address: [
|
92
|
-
{
|
93
|
-
type: Trustev::ADDRESS_TYPES[:standard],
|
94
|
-
first_name: 'Joe',
|
95
|
-
last_name: 'Bloggs',
|
96
|
-
address_1: '2011',
|
97
|
-
address_2: 'Imaginary Way',
|
98
|
-
address_3: '',
|
99
|
-
city: 'Anycity',
|
100
|
-
state: 'AnyState',
|
101
|
-
postal_code: '123456',
|
102
|
-
country_code: 'US'
|
103
|
-
}
|
104
|
-
],
|
105
|
-
item: [
|
106
|
-
{
|
107
|
-
name: 'T-Shirt',
|
108
|
-
url: 'T-shirts.com',
|
109
|
-
image_url: 'T-shirts.com/Trustev-T-Shirt',
|
110
|
-
quantity: 1,
|
111
|
-
total_before_tax: 40.0,
|
112
|
-
total_discount: 0.0,
|
113
|
-
total_tax: 10,
|
114
|
-
total_item_value: 50.0
|
115
|
-
}
|
116
|
-
]
|
117
|
-
},
|
118
|
-
customer: {
|
119
|
-
first_name: 'John',
|
120
|
-
last_name: 'Doe',
|
121
|
-
phone_number: '00353861658789',
|
122
|
-
date_of_birth: 1403256280325,
|
123
|
-
email: [
|
124
|
-
{
|
125
|
-
is_default: true,
|
126
|
-
email_address: "jondoe@mail.com"
|
127
|
-
}
|
128
|
-
],
|
129
|
-
address: [
|
130
|
-
{
|
131
|
-
type: Trustev::ADDRESS_TYPES[:standard],
|
132
|
-
first_name: 'Joe',
|
133
|
-
last_name: 'Bloggs',
|
134
|
-
address_1: '2011',
|
135
|
-
address_2: 'Imaginary Way',
|
136
|
-
address_3: '',
|
137
|
-
city: 'Anycity',
|
138
|
-
state: 'AnyState',
|
139
|
-
postal_code: '123456',
|
140
|
-
country_code: 'US',
|
141
|
-
is_default: true
|
142
|
-
}
|
143
|
-
]
|
144
|
-
},
|
145
|
-
session_id: 'f39767e2-0cb5-hk97-a296-4619c269d59d'
|
146
|
-
}
|
147
|
-
)
|
148
|
-
```
|
149
|
-
|
150
|
-
#### Update an existing transaction
|
151
|
-
|
152
|
-
This takes the same parameters as `Trustev::transaction.create`
|
153
|
-
```ruby
|
154
|
-
transaction = Trustev::Transaction.new('1234abcd')
|
155
|
-
transaction.update({...})
|
156
|
-
```
|
157
|
-
|
158
|
-
#### Set transaction status
|
159
|
-
|
160
|
-
```ruby
|
161
|
-
# transaction.set_status(status, reason, comment)
|
162
|
-
transaction = Trustev::Transaction.new('1234abcd')
|
163
|
-
transaction.set_status(Trustev::STATUS_TYPES[:refunded],
|
164
|
-
Trustev::REASON_TYPES[:complaint],
|
165
|
-
'Transaction was refunded due to a complaint')
|
166
|
-
```
|
167
|
-
|
168
|
-
| Status Code | Description |
|
169
|
-
|-------------|-------------|
|
170
|
-
| 0 | Init |
|
171
|
-
| 1 | Placed |
|
172
|
-
| 2 | Refunded |
|
173
|
-
| 3 | Rejected |
|
174
|
-
| 5 | Completed |
|
175
|
-
| 8 | Chargeback |
|
176
|
-
|
177
|
-
| Reason Code | Description |
|
178
|
-
|-------------|-------------|
|
179
|
-
| 0 | System |
|
180
|
-
| 1 | Fraud |
|
181
|
-
| 2 | Complaint |
|
182
|
-
| 3 | Remorse |
|
183
|
-
| 4 | Other |
|
184
|
-
|
185
|
-
Comment: This allows you to include and extra comment on the status of the transaction
|
186
|
-
|
187
|
-
See the [trustev API documentation](http://developers.trustev.com/#addtransactionstatus) for up to date codes.
|
188
|
-
|
189
|
-
#### Add transaction BIN
|
190
|
-
|
191
|
-
```ruby
|
192
|
-
# transaction.set_bin(bin, transaction_number)
|
193
|
-
transaction = Trustev::Transaction.new('1234abcd')
|
194
|
-
transaction.set_bin(123456)
|
195
|
-
```
|
196
|
-
|
197
|
-
### Social
|
198
|
-
|
199
|
-
#### Add Social
|
200
|
-
|
201
|
-
```ruby
|
202
|
-
Trustev::Social.create([
|
203
|
-
{
|
204
|
-
type: Trustev::SOCIAL_NETWORK_TYPES[:facebook],
|
205
|
-
id: 780219323,
|
206
|
-
short_term_token: 'CAAGEIkkiTM4BAHR9ar4XH4uTqK6JaOF1aIGbCBrsQgocHUh9',
|
207
|
-
long_term_token: 'CAAGEIkkiTM4BAJyc0pMxQQAprOrNlMRODaVQgQtcvlNO7Rvab',
|
208
|
-
short_term_expiry: 1391448969000,
|
209
|
-
long_term_expiry: 1391449878000,
|
210
|
-
secret: '84bcd7da0e967139652f7ce90k4c859e'
|
211
|
-
}
|
212
|
-
])
|
213
|
-
```
|
214
|
-
|
215
|
-
| Social Network Type | Name |
|
216
|
-
|---------------------|----------|
|
217
|
-
| 0 | Facebook |
|
218
|
-
| 1 | Twitter |
|
219
|
-
| 2 | Linkedin |
|
220
|
-
| 3 | Trustev |
|
221
|
-
|
222
|
-
See the [trustev API documentation](http://developers.trustev.com/#addprofile) for up to types.
|
223
|
-
|
224
|
-
#### Update Social
|
225
|
-
|
226
|
-
This is similar `Trustev::Social.create`, but only accepts ONE hash, instead of an array of hashes.
|
227
|
-
```ruby
|
228
|
-
Trustev::Social.update({
|
229
|
-
type: Trustev::SOCIAL_NETWORK_TYPES[:facebook],
|
230
|
-
id: 780219323,
|
231
|
-
short_term_token: 'CAAGEIkkiTM4BAHR9ar4XH4uTqK6JaOF1aIGbCBrsQgocHUh9',
|
232
|
-
long_term_token: 'CAAGEIkkiTM4BAJyc0pMxQQAprOrNlMRODaVQgQtcvlNO7Rvab',
|
233
|
-
short_term_expiry: 1391448969000,
|
234
|
-
long_term_expiry: 1391449878000,
|
235
|
-
secret: '84bcd7da0e967139652f7ce90k4c859e'
|
236
|
-
})
|
237
|
-
```
|
238
|
-
|
239
|
-
#### Delete Social
|
240
|
-
```ruby
|
241
|
-
# Trustev::Social.delete(social_network_type, social_network_id)
|
242
|
-
Trustev::Social.delete(Trustev::SOCIAL_NETWORK_TYPES[:facebook], 780219323)
|
243
|
-
```
|
244
|
-
|
245
|
-
### Profile
|
246
|
-
|
247
|
-
#### Retrieve Raw Scores
|
248
|
-
```ruby
|
249
|
-
# profile = Trustev::Profile.new(transaction_number)
|
250
|
-
# profile.retrieve_scores
|
251
|
-
profile = Trustev::Profile.new('1234abcd')
|
252
|
-
profile.retrieve_scores
|
253
|
-
```
|
254
|
-
|
255
|
-
This returns a hash with the Trustev Score.
|
256
|
-
|
257
|
-
###### Sample Response
|
258
|
-
```ruby
|
259
|
-
{
|
260
|
-
Code: 200,
|
261
|
-
Message: "Success",
|
262
|
-
Profile: {
|
263
|
-
Sources: [{
|
264
|
-
Scores: [{
|
265
|
-
Confidence : 100,
|
266
|
-
Parameter : 0,
|
267
|
-
Score : 73
|
268
|
-
}],
|
269
|
-
Source : 7
|
270
|
-
}]
|
271
|
-
}
|
272
|
-
}
|
273
|
-
```
|
274
|
-
|
275
|
-
| Response Parameter | Description |
|
276
|
-
|----------------------|-----------------------------------------------------------------------------------------------------------------------------------|
|
277
|
-
| Code (int) | This will be a basic HTML response code |
|
278
|
-
| Message (string) | This will be a response string which should give your some basic information on the status of you response eg. “Success” or “NOK” |
|
279
|
-
| Sources (array) | This will be an array of Trustev Scores from different Trustev Sources |
|
280
|
-
| Scores (array) | This will be an array of Trustev Scores based on different Score parameters |
|
281
|
-
| Confidence (decimal) | This will be a Trustev Confidence which outlines Trustev’s Condfidence in the score it has returned |
|
282
|
-
| Parameter (int) | This will be The Trustev parameter which the score is based on |
|
283
|
-
| Score (decimal) | This is the Trustev Score |
|
284
|
-
| Source (int) | This will be the TrustevProfile Score Source on which the Trustev Scores Array was based on |
|
285
|
-
|
286
|
-
#### Retrieve Overall Trustev score
|
287
|
-
```ruby
|
288
|
-
# profile = Trustev::Profile.new(transaction_number)
|
289
|
-
# profile.get_overall_score
|
290
|
-
profile = Trustev::Profile.new('1234abcd')
|
291
|
-
profile.get_overall_score
|
292
|
-
```
|
293
|
-
|
294
|
-
This returns the overall Trustev score
|
295
|
-
|
296
|
-
#### Retrieve A Specific score
|
297
|
-
```ruby
|
298
|
-
# profile = Trustev::Profile.new(transaction_number)
|
299
|
-
# profile.get_score(source_id, parameter_id)
|
300
|
-
profile = Trustev::Profile.new('1234abcd')
|
301
|
-
profile.get_score(Trustev::SCORE_SOURCES[:trustev], Trustev::SCORE_PARAMETERS[:overall])
|
302
|
-
```
|
303
|
-
|
304
|
-
This returns a score from a specific source and parameter
|
305
|
-
|
306
|
-
| Score Source | Description |
|
307
|
-
|--------------|-------------|
|
308
|
-
| 0 | Address |
|
309
|
-
| 1 | Behavior |
|
310
|
-
| 2 | Device |
|
311
|
-
| 3 | Email |
|
312
|
-
| 4 | Facebook |
|
313
|
-
| 5 | IP |
|
314
|
-
| 6 | Transaction |
|
315
|
-
| 7 | Trustev |
|
316
|
-
| 8 | Velocity |
|
317
|
-
|
318
|
-
| Parameter Code | Description |
|
319
|
-
|----------------|-------------|
|
320
|
-
| 0 | Overall |
|
321
|
-
| 1 | Billing |
|
322
|
-
| 2 | Delivery |
|
323
|
-
| 3 | Input |
|
324
|
-
| 4 | Domain |
|
325
|
-
| 5 | Address |
|
326
|
-
| 6 | IP |
|
327
|
-
| 7 | Proxy |
|
328
|
-
| 8 | VPN |
|
329
|
-
| 9 | Value |
|
330
|
-
| 10 | Velocity |
|
331
|
-
| 11 | Legitimacy |
|
332
|
-
| 12 | Pattern |
|
333
|
-
| 13 | Hustle |
|
334
|
-
|
335
|
-
See the [trustev API documentation](http://developers.trustev.com/#getprofile) for up to date response info.
|
336
|
-
|
337
|
-
|
338
|
-
## Contributing
|
12
|
+
# Contributing
|
339
13
|
|
340
14
|
1. Fork it ( https://github.com/giftcardzen/trustev/fork )
|
341
15
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
data/Rakefile
CHANGED
data/lib/trustev.rb
CHANGED
@@ -1,13 +1,9 @@
|
|
1
1
|
require 'httparty'
|
2
2
|
require 'multi_json'
|
3
|
+
require 'require_all'
|
3
4
|
|
4
5
|
require 'trustev/version'
|
5
|
-
require 'trustev/authenticate'
|
6
|
-
require 'trustev/profile'
|
7
|
-
require 'trustev/social'
|
8
|
-
require 'trustev/transaction'
|
9
6
|
require 'trustev/error'
|
10
|
-
require 'trustev/digital_signature'
|
11
7
|
|
12
8
|
module Trustev
|
13
9
|
@@username = nil
|
@@ -15,11 +11,12 @@ module Trustev
|
|
15
11
|
@@shared_secret = nil
|
16
12
|
@@private_key = nil
|
17
13
|
@@public_key = nil
|
18
|
-
@@
|
19
|
-
@@api_version = '1.2'
|
14
|
+
@@api_version = nil
|
20
15
|
@@token = nil
|
21
16
|
@@token_expire = nil
|
22
17
|
|
18
|
+
API_VERSIONS = %w(1.2 2.0)
|
19
|
+
|
23
20
|
ADDRESS_TYPES = {
|
24
21
|
standard: 0,
|
25
22
|
billing: 1,
|
@@ -30,53 +27,8 @@ module Trustev
|
|
30
27
|
facebook: 0,
|
31
28
|
twitter: 1,
|
32
29
|
linkedin: 2,
|
33
|
-
trustev: 3
|
34
|
-
|
35
|
-
|
36
|
-
STATUS_TYPES = {
|
37
|
-
init: 0,
|
38
|
-
placed: 1,
|
39
|
-
refunded: 2,
|
40
|
-
rejected: 3,
|
41
|
-
completed: 5,
|
42
|
-
chargeback: 8
|
43
|
-
}
|
44
|
-
|
45
|
-
REASON_TYPES = {
|
46
|
-
system: 0,
|
47
|
-
fraud: 1,
|
48
|
-
complaint: 2,
|
49
|
-
remorse: 3,
|
50
|
-
other: 4
|
51
|
-
}
|
52
|
-
|
53
|
-
SCORE_SOURCES = {
|
54
|
-
address: 0,
|
55
|
-
behaviour: 1,
|
56
|
-
device: 2,
|
57
|
-
email: 3,
|
58
|
-
facebook: 4,
|
59
|
-
IP: 5,
|
60
|
-
transaction: 6,
|
61
|
-
trustev: 7,
|
62
|
-
velocity: 8
|
63
|
-
}
|
64
|
-
|
65
|
-
SCORE_PARAMETERS = {
|
66
|
-
overall: 0,
|
67
|
-
billing: 1,
|
68
|
-
delivery: 2,
|
69
|
-
input: 3,
|
70
|
-
domain: 4,
|
71
|
-
address: 5,
|
72
|
-
IP: 6,
|
73
|
-
proxy: 7,
|
74
|
-
VPN: 8,
|
75
|
-
value: 9,
|
76
|
-
velocity: 10,
|
77
|
-
legitimacy: 11,
|
78
|
-
pattern: 12,
|
79
|
-
hustle: 13
|
30
|
+
trustev: 3,
|
31
|
+
trustev_session: 4
|
80
32
|
}
|
81
33
|
|
82
34
|
def self.username=(username)
|
@@ -139,27 +91,33 @@ module Trustev
|
|
139
91
|
@@token_expire
|
140
92
|
end
|
141
93
|
|
142
|
-
def self.
|
94
|
+
def self.api_version
|
95
|
+
@@api_version
|
96
|
+
end
|
143
97
|
|
144
|
-
|
145
|
-
|
146
|
-
|
98
|
+
def self.api_version=(api_version)
|
99
|
+
@@api_version = api_version
|
100
|
+
raise Error.new("API v#{api_version} not supported.") unless API_VERSIONS.include? api_version
|
101
|
+
require_rel "trustev/#{api_version}"
|
102
|
+
end
|
103
|
+
|
104
|
+
def self.do_send_request(path, body, method, expect_json=false, requires_token=true)
|
105
|
+
Authenticate.retrieve_token if requires_token && invalid_token?
|
147
106
|
|
148
107
|
raise Error.new('Auth token missing or expired') if requires_token && invalid_token?
|
149
108
|
|
150
109
|
headers = { 'Content-Type' => 'application/json', 'Accept' => 'application/json' }
|
151
110
|
headers['X-Authorization'] = "#{@@username} #{@@token}" if requires_token
|
152
111
|
|
153
|
-
body = { request: body }
|
154
|
-
|
155
112
|
options = { body: body.to_json, headers: headers}
|
156
113
|
|
157
114
|
response = HTTParty.post(api_url(path), options) if method == 'POST'
|
158
115
|
response = HTTParty.get(api_url(path), options) if method == 'GET'
|
159
116
|
response = HTTParty.put(api_url(path), options) if method == 'PUT'
|
160
117
|
response = HTTParty.delete(api_url(path), options) if method == 'DELETE'
|
161
|
-
|
162
|
-
|
118
|
+
if response.code != 200
|
119
|
+
raise_error response
|
120
|
+
end
|
163
121
|
|
164
122
|
if expect_json
|
165
123
|
begin
|
@@ -171,10 +129,4 @@ module Trustev
|
|
171
129
|
|
172
130
|
response
|
173
131
|
end
|
174
|
-
|
175
|
-
private
|
176
|
-
|
177
|
-
def self.invalid_token?
|
178
|
-
@@token.nil? || @@token_expire-600 <= Time.now.to_i
|
179
|
-
end
|
180
132
|
end
|