amex 0.3.1 → 0.3.2
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.
- data/Gemfile +1 -1
- data/Gemfile.lock +2 -2
- data/README.md +2 -0
- data/amex-0.3.1.gem +0 -0
- data/lib/amex/client.rb +39 -21
- data/lib/amex/data/request.xml +1 -1
- data/lib/amex/version.rb +1 -1
- metadata +2 -1
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
GEM
|
2
2
|
remote: http://rubygems.org/
|
3
3
|
specs:
|
4
|
-
amex (0.3.
|
4
|
+
amex (0.3.2)
|
5
5
|
httparty
|
6
6
|
nokogiri
|
7
7
|
httparty (0.9.0)
|
@@ -15,6 +15,6 @@ PLATFORMS
|
|
15
15
|
ruby
|
16
16
|
|
17
17
|
DEPENDENCIES
|
18
|
-
amex (= 0.3.
|
18
|
+
amex (= 0.3.2)
|
19
19
|
httparty (= 0.9.0)
|
20
20
|
nokogiri (= 1.5.6)
|
data/README.md
CHANGED
@@ -20,6 +20,8 @@ __v0.3.0__ - Adds support for loading the transactions from the most recent stat
|
|
20
20
|
(but it's broken because I forgot to change something from testing :( )
|
21
21
|
__v0.3.1__ - Working version of v0.3.0 that will successfully load transactions
|
22
22
|
from the most recent statement
|
23
|
+
__v0.3.2__ - Generates a fake HardwareId in the first request, since I'm
|
24
|
+
paranoid about American Express blocking 'dummy_device_id'
|
23
25
|
|
24
26
|
### Usage
|
25
27
|
|
data/amex-0.3.1.gem
ADDED
Binary file
|
data/lib/amex/client.rb
CHANGED
@@ -13,27 +13,6 @@ module Amex
|
|
13
13
|
@password = password
|
14
14
|
end
|
15
15
|
|
16
|
-
def request_xml
|
17
|
-
xml = File.read(
|
18
|
-
File.expand_path(File.dirname(__FILE__) + '/data/request.xml')
|
19
|
-
)
|
20
|
-
|
21
|
-
username = @username
|
22
|
-
password = @password
|
23
|
-
timestamp = Time.now.to_i
|
24
|
-
|
25
|
-
ERB.new(xml).result(binding)
|
26
|
-
end
|
27
|
-
|
28
|
-
def statement_request_xml(card_index)
|
29
|
-
xml = File.read(
|
30
|
-
File.expand_path(File.dirname(__FILE__) + '/data/statement_request.xml')
|
31
|
-
)
|
32
|
-
|
33
|
-
security_token = @security_token
|
34
|
-
ERB.new(xml).result(binding)
|
35
|
-
end
|
36
|
-
|
37
16
|
def accounts
|
38
17
|
# This only supports one account for now, because I'm lazy and I
|
39
18
|
# hate traversing XML...
|
@@ -101,5 +80,44 @@ module Amex
|
|
101
80
|
|
102
81
|
end
|
103
82
|
|
83
|
+
private
|
84
|
+
|
85
|
+
def request_xml
|
86
|
+
# Generates XML for the first request for account information, taking
|
87
|
+
# an XML template and interpolating some parts with ERB
|
88
|
+
|
89
|
+
xml = File.read(
|
90
|
+
File.expand_path(File.dirname(__FILE__) + '/data/request.xml')
|
91
|
+
)
|
92
|
+
|
93
|
+
username = @username
|
94
|
+
password = @password
|
95
|
+
timestamp = Time.now.to_i
|
96
|
+
|
97
|
+
ERB.new(xml).result(binding)
|
98
|
+
end
|
99
|
+
|
100
|
+
def statement_request_xml(card_index)
|
101
|
+
# Generates XML for grabbing the last statement's transactions for a
|
102
|
+
# card, using the card_index attribute from an account's XML
|
103
|
+
|
104
|
+
xml = File.read(
|
105
|
+
File.expand_path(File.dirname(__FILE__) + '/data/statement_request.xml')
|
106
|
+
)
|
107
|
+
|
108
|
+
security_token = @security_token
|
109
|
+
ERB.new(xml).result(binding)
|
110
|
+
end
|
111
|
+
|
112
|
+
def hardware_id
|
113
|
+
# Generates a fake HardwareId - a 40 character alphanumeric lower-case
|
114
|
+
# string, which is passed in with the original API request
|
115
|
+
|
116
|
+
chars = 'abcdefghjkmnpqrstuvwxyz1234567890'
|
117
|
+
id = ''
|
118
|
+
40.times { id << chars[rand(chars.size)] }
|
119
|
+
id
|
120
|
+
end
|
121
|
+
|
104
122
|
end
|
105
123
|
end
|
data/lib/amex/data/request.xml
CHANGED
@@ -5,6 +5,6 @@
|
|
5
5
|
<ServiceVersion>1.0</ServiceVersion>
|
6
6
|
<Locale>en_GB</Locale>
|
7
7
|
<ServiceName>AccountSummaryService</ServiceName>
|
8
|
-
<DeviceInfo><HardwareId
|
8
|
+
<DeviceInfo><HardwareId><%= hardware_id %></HardwareId><OSBuild>iPhone OS 6.0.1</OSBuild><DeviceModel>iPhone</DeviceModel><Timestamp><%= timestamp %></Timestamp><TimeZoneOffset>0</TimeZoneOffset></DeviceInfo>
|
9
9
|
<LoginCredentials><UserID><%= username %></UserID><Password><%= password %></Password><RememberMeUIFlagSelected>false</RememberMeUIFlagSelected><ProfileDataContent></ProfileDataContent></LoginCredentials>
|
10
10
|
</XMLRequest>
|
data/lib/amex/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: amex
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -57,6 +57,7 @@ files:
|
|
57
57
|
- amex-0.1.0.gem
|
58
58
|
- amex-0.2.0.gem
|
59
59
|
- amex-0.3.0.gem
|
60
|
+
- amex-0.3.1.gem
|
60
61
|
- amex.gemspec
|
61
62
|
- example.rb
|
62
63
|
- lib/amex.rb
|