trustev 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 00973810bcd07e8c4b4c232d0a48bad7b484fb46
4
- data.tar.gz: 23d4ea284a284cf70c2b865ea6becbf6aed6f7a5
3
+ metadata.gz: 4a7eb937be25d3e9bd3ce8adc9b1ce2e843ef76f
4
+ data.tar.gz: a44cbe7e017e7ab8b0850ab3a13d1e0197a7c99f
5
5
  SHA512:
6
- metadata.gz: c18f46e7e522fdd882216aa27dbd93dd0f8c0b8d9a7a9ebc19ab55daca5050bca31e9c1e551dc77dd586e6a607a28a984bbedec67aa12eebe5fca7343efdee36
7
- data.tar.gz: 21fd158dc6f3ab6a2c8e39bbc6b856caa7e35f0bdc36b9acf3bb07a444a53b7034974650022fb157209c9be1695bb399d4c962aa12e0f1f8cb326a79ffd372e2
6
+ metadata.gz: 1dc315a24eed8540e07d19966c1a20a5fbcd3386a7b5e90b6d56a68dd5b0bdf50059aa29410d665bb708353f6f122936c585bb66df4303559dc780389857695d
7
+ data.tar.gz: 5e9669c3f697e7ea7af86af027844263aed672950585f367aadb84097a4a0aef80665779cf6c119206c923afcdad9559949cdc8a2bb21dff7ff82a91fc000bf2
data/README.md CHANGED
@@ -70,7 +70,7 @@ Only the following fields are required:
70
70
  transaction.create(
71
71
  {
72
72
  social_network: {
73
- type: 0,
73
+ type: Trustev::SOCIAL_NETWORK_TYPES[:facebook],
74
74
  id: '12345678'
75
75
  },
76
76
  transaction_data: {
@@ -83,7 +83,7 @@ Only the following fields are required:
83
83
  timestamp: 1391449224000,
84
84
  address: [
85
85
  {
86
- type: 0,
86
+ type: Trustev::ADDRESS_TYPES[:standard],
87
87
  first_name: 'Joe',
88
88
  last_name: 'Bloggs',
89
89
  address_1: '2011',
@@ -121,7 +121,7 @@ Only the following fields are required:
121
121
  ],
122
122
  address: [
123
123
  {
124
- type: 0,
124
+ type: Trustev::ADDRESS_TYPES[:standard],
125
125
  first_name: 'Joe',
126
126
  last_name: 'Bloggs',
127
127
  address_1: '2011',
@@ -153,7 +153,9 @@ This takes the same parameters as `Trustev::transaction.create`
153
153
  ```ruby
154
154
  # transaction.set_status(status, reason, comment)
155
155
  transaction = Trustev::Transaction.new('1234abcd')
156
- transaction.set_status(3, 2, 'Transaction was refused due to a Trustev Score of 35')
156
+ transaction.set_status(Trustev::STATUS_TYPES[:refunded],
157
+ Trustev::REASON_TYPES[:complaint],
158
+ 'Transaction was refunded due to a complaint')
157
159
  ```
158
160
 
159
161
  | Status Code | Description |
@@ -192,7 +194,7 @@ See the [trustev API documentation](http://developers.trustev.com/#addtransactio
192
194
  ```ruby
193
195
  Trustev::Social.create([
194
196
  {
195
- type: 0,
197
+ type: Trustev::SOCIAL_NETWORK_TYPES[:facebook],
196
198
  id: 780219323,
197
199
  short_term_token: 'CAAGEIkkiTM4BAHR9ar4XH4uTqK6JaOF1aIGbCBrsQgocHUh9',
198
200
  long_term_token: 'CAAGEIkkiTM4BAJyc0pMxQQAprOrNlMRODaVQgQtcvlNO7Rvab',
@@ -216,8 +218,8 @@ See the [trustev API documentation](http://developers.trustev.com/#addprofile) f
216
218
 
217
219
  This is similar `Trustev::Social.create`, but only accepts ONE hash, instead of an array of hashes.
218
220
  ```ruby
219
- Trustev::transaction.update({
220
- type: 0,
221
+ Trustev::Social.update({
222
+ type: Trustev::SOCIAL_NETWORK_TYPES[:facebook],
221
223
  id: 780219323,
222
224
  short_term_token: 'CAAGEIkkiTM4BAHR9ar4XH4uTqK6JaOF1aIGbCBrsQgocHUh9',
223
225
  long_term_token: 'CAAGEIkkiTM4BAJyc0pMxQQAprOrNlMRODaVQgQtcvlNO7Rvab',
@@ -230,7 +232,7 @@ This is similar `Trustev::Social.create`, but only accepts ONE hash, instead of
230
232
  #### Delete Social
231
233
  ```ruby
232
234
  # Trustev::Social.delete(social_network_type, social_network_id)
233
- Trustev::Social.delete(0, 780219323)
235
+ Trustev::Social.delete(Trustev::SOCIAL_NETWORK_TYPES[:facebook], 780219323)
234
236
  ```
235
237
 
236
238
  ### Profile
@@ -289,7 +291,7 @@ This returns the overall Trustev score
289
291
  # profile = Trustev::Profile.new(transaction_number)
290
292
  # profile.get_score(source_id, parameter_id)
291
293
  Trustev::Profile.retrieve('1234abcd')
292
- profile.get_score(7, 0)
294
+ profile.get_score(Trustev::SCORE_SOURCES[:trustev], Trustev::SCORE_PARAMETERS[:overall])
293
295
  ```
294
296
 
295
297
  This returns a score from a specific source and parameter
@@ -3,10 +3,6 @@ module Trustev
3
3
 
4
4
  SERVICE_URL = 'ProfileService.svc/rest/Transaction'
5
5
 
6
- SOURCES = [0, 1, 2, 3, 4, 5, 6, 7, 8]
7
-
8
- PARAMETERS = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]
9
-
10
6
  def initialize(transaction_number)
11
7
  raise Error.new('Transaction Number is required') if transaction_number.nil?
12
8
  @transaction_number = transaction_number
@@ -17,12 +13,12 @@ module Trustev
17
13
  end
18
14
 
19
15
  def get_overall_score
20
- get_score(7, 0)
16
+ get_score(Trustev::SCORE_SOURCES[:trustev], Trustev::SCORE_PARAMETERS[:overall])
21
17
  end
22
18
 
23
19
  def get_score(source_id, parameter_id)
24
- raise Error.new('Invalid Source') if SOURCES.index(source_id).nil?
25
- raise Error.new('Invalid Parameter') if PARAMETERS.index(parameter_id).nil?
20
+ raise Error.new('Invalid Source') if Trustev::SCORE_SOURCES.key(source_id).nil?
21
+ raise Error.new('Invalid Parameter') if Trustev::SCORE_PARAMETERS.key(parameter_id).nil?
26
22
  response = retrieve_scores
27
23
  response[:Profile][:Sources].each do | source |
28
24
  if source[:Source] == source_id
@@ -39,12 +39,6 @@ module Trustev
39
39
  TD TF TG TH TJ TK TL TM TN TO TR TT TV TW TZ UA UG UM US UY UZ
40
40
  VA VC VE VG VI VN VU WF WS YE YT ZA ZM ZW)
41
41
 
42
- ADDRESS_TYPES = [0, 1, 2]
43
-
44
- STATUS_TYPES = [0, 1, 2, 3, 5, 8]
45
-
46
- REASON_TYPES = [0, 1, 2, 3, 4]
47
-
48
42
  def initialize(transaction_number)
49
43
  raise Error.new('TransactionNumber is required.') if transaction_number.nil?
50
44
  @transaction_number = transaction_number
@@ -63,8 +57,8 @@ module Trustev
63
57
  end
64
58
 
65
59
  def set_status(status, reason, comment)
66
- raise Error.new('Invalid Status Code') if STATUS_TYPES.index(status).nil?
67
- raise Error.new('Invalid Reason Code') if REASON_TYPES.index(reason).nil?
60
+ raise Error.new('Invalid Status Code') if Trustev::STATUS_TYPES.key(status).nil?
61
+ raise Error.new('Invalid Reason Code') if Trustev::REASON_TYPES.key(reason).nil?
68
62
  raise Error.new('Status comment cannot be blank') if comment.nil? || comment.empty?
69
63
  body = {
70
64
  Status: status,
@@ -105,7 +99,7 @@ module Trustev
105
99
  def validate_address(address)
106
100
  address[:country_code] = 'NS' if address[:country_code].nil?
107
101
  raise Error.new('Invalid Country Code') if COUNTRY_CODES.index(address[:country_code]).nil?
108
- raise Error.new('Invalid Address Type') if ADDRESS_TYPES.index(address[:type]).nil?
102
+ raise Error.new('Invalid Address Type') if Trustev::ADDRESS_TYPES.key(address[:type]).nil?
109
103
  address
110
104
  end
111
105
 
@@ -1,3 +1,3 @@
1
1
  module Trustev
2
- VERSION = '0.1.0'
2
+ VERSION = '0.2.0'
3
3
  end
data/lib/trustev.rb CHANGED
@@ -19,6 +19,65 @@ module Trustev
19
19
  @@token = nil
20
20
  @@token_expire = nil
21
21
 
22
+ ADDRESS_TYPES = {
23
+ standard: 0,
24
+ billing: 1,
25
+ delivery: 2
26
+ }
27
+
28
+ SOCIAL_NETWORK_TYPES = {
29
+ facebook: 0,
30
+ twitter: 1,
31
+ linkedin: 2,
32
+ trustev: 3
33
+ }
34
+
35
+ STATUS_TYPES = {
36
+ init: 0,
37
+ placed: 1,
38
+ refunded: 2,
39
+ rejected: 3,
40
+ completed: 5,
41
+ chargeback: 8
42
+ }
43
+
44
+ REASON_TYPES = {
45
+ system: 0,
46
+ fraud: 1,
47
+ complaint: 2,
48
+ remorse: 3,
49
+ other: 4
50
+ }
51
+
52
+ SCORE_SOURCES = {
53
+ address: 0,
54
+ behaviour: 1,
55
+ device: 2,
56
+ email: 3,
57
+ facebook: 4,
58
+ IP: 5,
59
+ transaction: 6,
60
+ trustev: 7,
61
+ velocity: 8
62
+ }
63
+
64
+ SCORE_PARAMETERS = {
65
+ overall: 0,
66
+ billing: 1,
67
+ delivery: 2,
68
+ input: 3,
69
+ domain: 4,
70
+ address: 5,
71
+ IP: 6,
72
+ proxy: 7,
73
+ VPN: 8,
74
+ value: 9,
75
+ velocity: 10,
76
+ legitimacy: 11,
77
+ pattern: 12,
78
+ hustle: 13
79
+ }
80
+
22
81
  def self.username=(username)
23
82
  @@username = username
24
83
  end
data/test/profile_test.rb CHANGED
@@ -19,7 +19,7 @@ describe Trustev::Profile do
19
19
  score_data[:Profile].must_be_instance_of Hash
20
20
  score_data[:Profile][:Sources].must_be_instance_of Array
21
21
  score_data[:Profile][:Sources][0].must_be_instance_of Hash
22
- score_data[:Profile][:Sources][0][:Source].must_equal 7
22
+ score_data[:Profile][:Sources][0][:Source].must_equal Trustev::SCORE_SOURCES[:trustev]
23
23
  score_data[:Profile][:Sources][0][:Scores].must_be_instance_of Array
24
24
  score_data[:Profile][:Sources][0][:Scores][0][:Confidence].must_be_instance_of Fixnum
25
25
  score_data[:Profile][:Sources][0][:Scores][0][:Parameter].must_be_instance_of Fixnum
@@ -36,8 +36,8 @@ describe Trustev::Profile do
36
36
  describe 'when retrieving a specific score' do
37
37
  it 'must return that specific score' do
38
38
  @profile.retrieve_scores[:Profile][:Sources].each do | source |
39
- if source[:Source] == 7
40
- source[:Scores].each { | score | score[:Score].must_equal @profile.get_score(7, 0) if score[:Parameter] == 0 }
39
+ if source[:Source] == Trustev::SCORE_SOURCES[:trustev]
40
+ source[:Scores].each { | score | score[:Score].must_equal @profile.get_score(7, 0) if score[:Parameter] == Trustev::SCORE_PARAMETERS[:overall] }
41
41
  end
42
42
  end
43
43
  end
data/test/social_test.rb CHANGED
@@ -19,7 +19,7 @@ describe Trustev::Social do
19
19
  create_social
20
20
  Trustev::Social.update(
21
21
  {
22
- type: 0,
22
+ type: Trustev::SOCIAL_NETWORK_TYPES[:facebook],
23
23
  id: @social_network_id,
24
24
  short_term_token: 'CAAGEIkkiehQrXSIK9vHOiPnZB139M',
25
25
  long_term_token: 'CAAGXgR7VWu',
@@ -34,7 +34,7 @@ describe Trustev::Social do
34
34
  describe 'when deleting social network data' do
35
35
  it 'must return a good response code' do
36
36
  create_social
37
- Trustev::Social.delete(0, @social_network_id).code.must_equal 200
37
+ Trustev::Social.delete(Trustev::SOCIAL_NETWORK_TYPES[:facebook], @social_network_id).code.must_equal 200
38
38
  end
39
39
  end
40
40
 
@@ -43,7 +43,7 @@ describe Trustev::Social do
43
43
  def create_social
44
44
  Trustev::Social.create([
45
45
  {
46
- type: 0,
46
+ type: Trustev::SOCIAL_NETWORK_TYPES[:facebook],
47
47
  id: @social_network_id,
48
48
  short_term_token: 'CAAGEIkkiehQrXSIK9vHOiPnZB139M',
49
49
  long_term_token: 'CAAGXgR7VWu',
data/test/test_helper.rb CHANGED
@@ -10,7 +10,7 @@ Trustev.private_key = '65950d41f8d3ea86dc25aaf893ba15db'
10
10
  def build_transaction
11
11
  {
12
12
  social_network: {
13
- type: 0,
13
+ type: Trustev::SOCIAL_NETWORK_TYPES[:facebook],
14
14
  id: '780218520'
15
15
  },
16
16
  transaction_data: {
@@ -23,7 +23,7 @@ def build_transaction
23
23
  timestamp: 1391449224000,
24
24
  address: [
25
25
  {
26
- type: 0,
26
+ type: Trustev::ADDRESS_TYPES[:standard],
27
27
  first_name: 'Joe',
28
28
  last_name: 'Bloggs',
29
29
  address_1: '2011',
@@ -61,7 +61,7 @@ def build_transaction
61
61
  ],
62
62
  address: [
63
63
  {
64
- type: 0,
64
+ type: Trustev::ADDRESS_TYPES[:standard],
65
65
  first_name: 'Joe',
66
66
  last_name: 'Bloggs',
67
67
  address_1: '2011',
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: trustev
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jonah Hirsch
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-11-06 00:00:00.000000000 Z
11
+ date: 2014-11-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -142,7 +142,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
142
142
  version: '0'
143
143
  requirements: []
144
144
  rubyforge_project:
145
- rubygems_version: 2.2.2
145
+ rubygems_version: 2.4.2
146
146
  signing_key:
147
147
  specification_version: 4
148
148
  summary: Ruby wrapper for Trustev API.