omise 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (74) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +14 -0
  3. data/Gemfile +4 -0
  4. data/LICENSE.txt +22 -0
  5. data/README.md +56 -0
  6. data/Rakefile +8 -0
  7. data/data/ca_certificates.pem +105 -0
  8. data/lib/omise.rb +6 -0
  9. data/lib/omise/account.rb +8 -0
  10. data/lib/omise/all.rb +9 -0
  11. data/lib/omise/attributes.rb +63 -0
  12. data/lib/omise/balance.rb +8 -0
  13. data/lib/omise/card.rb +19 -0
  14. data/lib/omise/card_list.rb +22 -0
  15. data/lib/omise/charge.rb +55 -0
  16. data/lib/omise/config.rb +36 -0
  17. data/lib/omise/customer.rb +50 -0
  18. data/lib/omise/error.rb +12 -0
  19. data/lib/omise/list.rb +37 -0
  20. data/lib/omise/object.rb +60 -0
  21. data/lib/omise/refund.rb +32 -0
  22. data/lib/omise/refund_list.rb +19 -0
  23. data/lib/omise/resource.rb +43 -0
  24. data/lib/omise/singleton_resource.rb +21 -0
  25. data/lib/omise/testing/resource.rb +38 -0
  26. data/lib/omise/token.rb +26 -0
  27. data/lib/omise/transaction.rb +16 -0
  28. data/lib/omise/transfer.rb +32 -0
  29. data/lib/omise/util.rb +24 -0
  30. data/lib/omise/vault.rb +15 -0
  31. data/lib/omise/version.rb +3 -0
  32. data/omise.gemspec +25 -0
  33. data/test/fixtures/api.omise.co/account-get.json +6 -0
  34. data/test/fixtures/api.omise.co/balance-get.json +7 -0
  35. data/test/fixtures/api.omise.co/charges-get.json +59 -0
  36. data/test/fixtures/api.omise.co/charges-post.json +36 -0
  37. data/test/fixtures/api.omise.co/charges/404-get.json +6 -0
  38. data/test/fixtures/api.omise.co/charges/chrg_test_4yq7duw15p9hdrjp8oq-get.json +58 -0
  39. data/test/fixtures/api.omise.co/charges/chrg_test_4yq7duw15p9hdrjp8oq-patch.json +58 -0
  40. data/test/fixtures/api.omise.co/charges/chrg_test_4yq7duw15p9hdrjp8oq/refunds-get.json +21 -0
  41. data/test/fixtures/api.omise.co/charges/chrg_test_4yq7duw15p9hdrjp8oq/refunds-post.json +10 -0
  42. data/test/fixtures/api.omise.co/charges/chrg_test_4yq7duw15p9hdrjp8oq/refunds/404-get.json +6 -0
  43. data/test/fixtures/api.omise.co/charges/chrg_test_4yq7duw15p9hdrjp8oq/refunds/rfnd_test_4yqmv79ahghsiz23y3c-get.json +10 -0
  44. data/test/fixtures/api.omise.co/customers-get.json +49 -0
  45. data/test/fixtures/api.omise.co/customers-post.json +22 -0
  46. data/test/fixtures/api.omise.co/customers/404-get.json +6 -0
  47. data/test/fixtures/api.omise.co/customers/cust_test_4yq6txdpfadhbaqnwp3-delete.json +6 -0
  48. data/test/fixtures/api.omise.co/customers/cust_test_4yq6txdpfadhbaqnwp3-get.json +39 -0
  49. data/test/fixtures/api.omise.co/customers/cust_test_4yq6txdpfadhbaqnwp3-patch.json +39 -0
  50. data/test/fixtures/api.omise.co/customers/cust_test_4yq6txdpfadhbaqnwp3/cards/404-get.json +6 -0
  51. data/test/fixtures/api.omise.co/customers/cust_test_4yq6txdpfadhbaqnwp3/cards/card_test_4yq6tuucl9h4erukfl0-delete.json +6 -0
  52. data/test/fixtures/api.omise.co/customers/cust_test_4yq6txdpfadhbaqnwp3/cards/card_test_4yq6tuucl9h4erukfl0-get.json +18 -0
  53. data/test/fixtures/api.omise.co/customers/cust_test_4yq6txdpfadhbaqnwp3/cards/card_test_4yq6tuucl9h4erukfl0-patch.json +18 -0
  54. data/test/fixtures/api.omise.co/transactions-get.json +26 -0
  55. data/test/fixtures/api.omise.co/transactions/trxn_test_4yq7duwb9jts1vxgqua-get.json +8 -0
  56. data/test/fixtures/api.omise.co/transactions/trxn_test_4yqafnvlztbf3908vs1-get.json +8 -0
  57. data/test/fixtures/api.omise.co/transactions/trxn_test_4yqmv79fzpy0gmz5mmq-get.json +8 -0
  58. data/test/fixtures/api.omise.co/transfers-get.json +24 -0
  59. data/test/fixtures/api.omise.co/transfers-post.json +14 -0
  60. data/test/fixtures/api.omise.co/transfers/trsf_test_4yqacz8t3cbipcj766u-get.json +14 -0
  61. data/test/fixtures/vault.omise.co/tokens-post.json +25 -0
  62. data/test/fixtures/vault.omise.co/tokens/tokn_test_4yq8lbecl0q6dsjzxr5-get.json +25 -0
  63. data/test/omise/test_account.rb +19 -0
  64. data/test/omise/test_balance.rb +19 -0
  65. data/test/omise/test_card.rb +52 -0
  66. data/test/omise/test_charge.rb +56 -0
  67. data/test/omise/test_customer.rb +59 -0
  68. data/test/omise/test_refund.rb +41 -0
  69. data/test/omise/test_token.rb +31 -0
  70. data/test/omise/test_transaction.rb +18 -0
  71. data/test/omise/test_transfer.rb +24 -0
  72. data/test/support.rb +12 -0
  73. data/test/test_omise.rb +7 -0
  74. metadata +214 -0
@@ -0,0 +1,41 @@
1
+ require "support"
2
+
3
+ class TestRefund < Minitest::Test
4
+ def setup
5
+ @refunds = Omise::Charge.retrieve("chrg_test_4yq7duw15p9hdrjp8oq").refunds
6
+ @refund = @refunds.retrieve("rfnd_test_4yqmv79ahghsiz23y3c")
7
+ end
8
+
9
+ def test_that_we_can_retrieve_a_refund
10
+ assert_instance_of Omise::Refund, @refund
11
+ assert_equal "rfnd_test_4yqmv79ahghsiz23y3c", @refund.id
12
+ end
13
+
14
+ def test_that_we_can_create_a_refund
15
+ refund = @refunds.create(amount: 10000)
16
+
17
+ assert_instance_of Omise::Refund, refund
18
+ assert_equal "rfnd_test_4yqmv79ahghsiz23y3c", refund.id
19
+ end
20
+
21
+ def test_that_a_refund_can_be_reloaded
22
+ @refund.attributes.taint
23
+ @refund.reload
24
+
25
+ refute @refund.attributes.tainted?
26
+ end
27
+
28
+ def test_that_retrieveing_a_non_existing_refund_will_raise_an_error
29
+ assert_raises Omise::Error do
30
+ @refunds.retrieve("404")
31
+ end
32
+ end
33
+
34
+ def test_that_a_refund_belongs_to_a_charge
35
+ assert_instance_of Omise::Charge, @refund.charge
36
+ end
37
+
38
+ def test_that_a_refund_has_a_transaction
39
+ assert_instance_of Omise::Transaction, @refund.transaction
40
+ end
41
+ end
@@ -0,0 +1,31 @@
1
+ require "support"
2
+
3
+ class TestToken < Minitest::Test
4
+ def setup
5
+ @token = Omise::Token.retrieve("tokn_test_4yq8lbecl0q6dsjzxr5")
6
+ end
7
+
8
+ def test_that_we_can_create_a_token
9
+ token = Omise::Token.create({
10
+ name: "JOHN DOE",
11
+ number: "4242424242424242",
12
+ expiration_month: "1",
13
+ expiration_year: "2017",
14
+ security_code: "123"
15
+ })
16
+
17
+ assert_instance_of Omise::Token, token
18
+ end
19
+
20
+ def test_that_we_can_retrieve_a_token
21
+ assert_instance_of Omise::Token, @token
22
+ assert_equal "tokn_test_4yq8lbecl0q6dsjzxr5", @token.id
23
+ end
24
+
25
+ def test_that_we_can_reload_a_token
26
+ @token.attributes.taint
27
+ @token.reload
28
+
29
+ refute @token.attributes.tainted?
30
+ end
31
+ end
@@ -0,0 +1,18 @@
1
+ require "support"
2
+
3
+ class TestTransaction < Minitest::Test
4
+ def setup
5
+ @transaction = Omise::Transaction.retrieve("trxn_test_4yq7duwb9jts1vxgqua")
6
+ end
7
+
8
+ def test_that_we_can_retrieve_a_transaction
9
+ assert_instance_of Omise::Transaction, @transaction
10
+ assert_equal "trxn_test_4yq7duwb9jts1vxgqua", @transaction.id
11
+ end
12
+
13
+ def test_that_we_can_list_all_transaction
14
+ transactions = Omise::Transaction.list
15
+
16
+ assert_instance_of Omise::List, transactions
17
+ end
18
+ end
@@ -0,0 +1,24 @@
1
+ require "support"
2
+
3
+ class TestTransfer < Minitest::Test
4
+ def setup
5
+ @transfer = Omise::Transfer.retrieve("trsf_test_4yqacz8t3cbipcj766u")
6
+ end
7
+
8
+ def test_that_we_can_create_a_transfer
9
+ transfer = Omise::Transfer.create
10
+
11
+ assert_instance_of Omise::Transfer, @transfer
12
+ end
13
+
14
+ def test_that_we_can_retrieve_a_transfer
15
+ assert_instance_of Omise::Transfer, @transfer
16
+ assert_equal "trsf_test_4yqacz8t3cbipcj766u", @transfer.id
17
+ end
18
+
19
+ def test_that_we_can_list_all_transfer
20
+ transfers = Omise::Transfer.list
21
+
22
+ assert_instance_of Omise::List, transfers
23
+ end
24
+ end
@@ -0,0 +1,12 @@
1
+ require "rubygems"
2
+ require "bundler/setup"
3
+
4
+ Bundler.require(:default, :test)
5
+
6
+ Omise.test!
7
+
8
+ # Dummy Keys
9
+ Omise.api_key = "pkey_test_4yq6tct0llin5nyyi5l"
10
+ Omise.vault_key = "skey_test_4yq6tct0lblmed2yp5t"
11
+
12
+ require "minitest/autorun"
@@ -0,0 +1,7 @@
1
+ require "support"
2
+
3
+ class TestOmise < Minitest::Test
4
+ def test_the_version
5
+ assert_equal "0.0.1", Omise::VERSION
6
+ end
7
+ end
metadata ADDED
@@ -0,0 +1,214 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: omise
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Robin Clart
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-01-19 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rest-client
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: 1.7.2
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: 1.7.2
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: '1.7'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: '1.7'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ~>
46
+ - !ruby/object:Gem::Version
47
+ version: '10.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: '10.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: minitest
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: 5.4.2
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ~>
67
+ - !ruby/object:Gem::Version
68
+ version: 5.4.2
69
+ description:
70
+ email:
71
+ - robin@omise.co
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - .gitignore
77
+ - Gemfile
78
+ - LICENSE.txt
79
+ - README.md
80
+ - Rakefile
81
+ - data/ca_certificates.pem
82
+ - lib/omise.rb
83
+ - lib/omise/account.rb
84
+ - lib/omise/all.rb
85
+ - lib/omise/attributes.rb
86
+ - lib/omise/balance.rb
87
+ - lib/omise/card.rb
88
+ - lib/omise/card_list.rb
89
+ - lib/omise/charge.rb
90
+ - lib/omise/config.rb
91
+ - lib/omise/customer.rb
92
+ - lib/omise/error.rb
93
+ - lib/omise/list.rb
94
+ - lib/omise/object.rb
95
+ - lib/omise/refund.rb
96
+ - lib/omise/refund_list.rb
97
+ - lib/omise/resource.rb
98
+ - lib/omise/singleton_resource.rb
99
+ - lib/omise/testing/resource.rb
100
+ - lib/omise/token.rb
101
+ - lib/omise/transaction.rb
102
+ - lib/omise/transfer.rb
103
+ - lib/omise/util.rb
104
+ - lib/omise/vault.rb
105
+ - lib/omise/version.rb
106
+ - omise.gemspec
107
+ - test/fixtures/api.omise.co/account-get.json
108
+ - test/fixtures/api.omise.co/balance-get.json
109
+ - test/fixtures/api.omise.co/charges-get.json
110
+ - test/fixtures/api.omise.co/charges-post.json
111
+ - test/fixtures/api.omise.co/charges/404-get.json
112
+ - test/fixtures/api.omise.co/charges/chrg_test_4yq7duw15p9hdrjp8oq-get.json
113
+ - test/fixtures/api.omise.co/charges/chrg_test_4yq7duw15p9hdrjp8oq-patch.json
114
+ - test/fixtures/api.omise.co/charges/chrg_test_4yq7duw15p9hdrjp8oq/refunds-get.json
115
+ - test/fixtures/api.omise.co/charges/chrg_test_4yq7duw15p9hdrjp8oq/refunds-post.json
116
+ - test/fixtures/api.omise.co/charges/chrg_test_4yq7duw15p9hdrjp8oq/refunds/404-get.json
117
+ - test/fixtures/api.omise.co/charges/chrg_test_4yq7duw15p9hdrjp8oq/refunds/rfnd_test_4yqmv79ahghsiz23y3c-get.json
118
+ - test/fixtures/api.omise.co/customers-get.json
119
+ - test/fixtures/api.omise.co/customers-post.json
120
+ - test/fixtures/api.omise.co/customers/404-get.json
121
+ - test/fixtures/api.omise.co/customers/cust_test_4yq6txdpfadhbaqnwp3-delete.json
122
+ - test/fixtures/api.omise.co/customers/cust_test_4yq6txdpfadhbaqnwp3-get.json
123
+ - test/fixtures/api.omise.co/customers/cust_test_4yq6txdpfadhbaqnwp3-patch.json
124
+ - test/fixtures/api.omise.co/customers/cust_test_4yq6txdpfadhbaqnwp3/cards/404-get.json
125
+ - test/fixtures/api.omise.co/customers/cust_test_4yq6txdpfadhbaqnwp3/cards/card_test_4yq6tuucl9h4erukfl0-delete.json
126
+ - test/fixtures/api.omise.co/customers/cust_test_4yq6txdpfadhbaqnwp3/cards/card_test_4yq6tuucl9h4erukfl0-get.json
127
+ - test/fixtures/api.omise.co/customers/cust_test_4yq6txdpfadhbaqnwp3/cards/card_test_4yq6tuucl9h4erukfl0-patch.json
128
+ - test/fixtures/api.omise.co/transactions-get.json
129
+ - test/fixtures/api.omise.co/transactions/trxn_test_4yq7duwb9jts1vxgqua-get.json
130
+ - test/fixtures/api.omise.co/transactions/trxn_test_4yqafnvlztbf3908vs1-get.json
131
+ - test/fixtures/api.omise.co/transactions/trxn_test_4yqmv79fzpy0gmz5mmq-get.json
132
+ - test/fixtures/api.omise.co/transfers-get.json
133
+ - test/fixtures/api.omise.co/transfers-post.json
134
+ - test/fixtures/api.omise.co/transfers/trsf_test_4yqacz8t3cbipcj766u-get.json
135
+ - test/fixtures/vault.omise.co/tokens-post.json
136
+ - test/fixtures/vault.omise.co/tokens/tokn_test_4yq8lbecl0q6dsjzxr5-get.json
137
+ - test/omise/test_account.rb
138
+ - test/omise/test_balance.rb
139
+ - test/omise/test_card.rb
140
+ - test/omise/test_charge.rb
141
+ - test/omise/test_customer.rb
142
+ - test/omise/test_refund.rb
143
+ - test/omise/test_token.rb
144
+ - test/omise/test_transaction.rb
145
+ - test/omise/test_transfer.rb
146
+ - test/support.rb
147
+ - test/test_omise.rb
148
+ homepage: https://www.omise.co/
149
+ licenses:
150
+ - MIT
151
+ metadata: {}
152
+ post_install_message:
153
+ rdoc_options: []
154
+ require_paths:
155
+ - lib
156
+ required_ruby_version: !ruby/object:Gem::Requirement
157
+ requirements:
158
+ - - '>='
159
+ - !ruby/object:Gem::Version
160
+ version: '0'
161
+ required_rubygems_version: !ruby/object:Gem::Requirement
162
+ requirements:
163
+ - - '>='
164
+ - !ruby/object:Gem::Version
165
+ version: '0'
166
+ requirements: []
167
+ rubyforge_project:
168
+ rubygems_version: 2.0.14
169
+ signing_key:
170
+ specification_version: 4
171
+ summary: Omise Ruby client
172
+ test_files:
173
+ - test/fixtures/api.omise.co/account-get.json
174
+ - test/fixtures/api.omise.co/balance-get.json
175
+ - test/fixtures/api.omise.co/charges-get.json
176
+ - test/fixtures/api.omise.co/charges-post.json
177
+ - test/fixtures/api.omise.co/charges/404-get.json
178
+ - test/fixtures/api.omise.co/charges/chrg_test_4yq7duw15p9hdrjp8oq-get.json
179
+ - test/fixtures/api.omise.co/charges/chrg_test_4yq7duw15p9hdrjp8oq-patch.json
180
+ - test/fixtures/api.omise.co/charges/chrg_test_4yq7duw15p9hdrjp8oq/refunds-get.json
181
+ - test/fixtures/api.omise.co/charges/chrg_test_4yq7duw15p9hdrjp8oq/refunds-post.json
182
+ - test/fixtures/api.omise.co/charges/chrg_test_4yq7duw15p9hdrjp8oq/refunds/404-get.json
183
+ - test/fixtures/api.omise.co/charges/chrg_test_4yq7duw15p9hdrjp8oq/refunds/rfnd_test_4yqmv79ahghsiz23y3c-get.json
184
+ - test/fixtures/api.omise.co/customers-get.json
185
+ - test/fixtures/api.omise.co/customers-post.json
186
+ - test/fixtures/api.omise.co/customers/404-get.json
187
+ - test/fixtures/api.omise.co/customers/cust_test_4yq6txdpfadhbaqnwp3-delete.json
188
+ - test/fixtures/api.omise.co/customers/cust_test_4yq6txdpfadhbaqnwp3-get.json
189
+ - test/fixtures/api.omise.co/customers/cust_test_4yq6txdpfadhbaqnwp3-patch.json
190
+ - test/fixtures/api.omise.co/customers/cust_test_4yq6txdpfadhbaqnwp3/cards/404-get.json
191
+ - test/fixtures/api.omise.co/customers/cust_test_4yq6txdpfadhbaqnwp3/cards/card_test_4yq6tuucl9h4erukfl0-delete.json
192
+ - test/fixtures/api.omise.co/customers/cust_test_4yq6txdpfadhbaqnwp3/cards/card_test_4yq6tuucl9h4erukfl0-get.json
193
+ - test/fixtures/api.omise.co/customers/cust_test_4yq6txdpfadhbaqnwp3/cards/card_test_4yq6tuucl9h4erukfl0-patch.json
194
+ - test/fixtures/api.omise.co/transactions-get.json
195
+ - test/fixtures/api.omise.co/transactions/trxn_test_4yq7duwb9jts1vxgqua-get.json
196
+ - test/fixtures/api.omise.co/transactions/trxn_test_4yqafnvlztbf3908vs1-get.json
197
+ - test/fixtures/api.omise.co/transactions/trxn_test_4yqmv79fzpy0gmz5mmq-get.json
198
+ - test/fixtures/api.omise.co/transfers-get.json
199
+ - test/fixtures/api.omise.co/transfers-post.json
200
+ - test/fixtures/api.omise.co/transfers/trsf_test_4yqacz8t3cbipcj766u-get.json
201
+ - test/fixtures/vault.omise.co/tokens-post.json
202
+ - test/fixtures/vault.omise.co/tokens/tokn_test_4yq8lbecl0q6dsjzxr5-get.json
203
+ - test/omise/test_account.rb
204
+ - test/omise/test_balance.rb
205
+ - test/omise/test_card.rb
206
+ - test/omise/test_charge.rb
207
+ - test/omise/test_customer.rb
208
+ - test/omise/test_refund.rb
209
+ - test/omise/test_token.rb
210
+ - test/omise/test_transaction.rb
211
+ - test/omise/test_transfer.rb
212
+ - test/support.rb
213
+ - test/test_omise.rb
214
+ has_rdoc: