omise 0.1.1 → 0.1.4

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.
Files changed (43) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +23 -0
  3. data/README.md +44 -33
  4. data/lib/omise/all.rb +2 -0
  5. data/lib/omise/bank_account.rb +6 -0
  6. data/lib/omise/card.rb +1 -1
  7. data/lib/omise/card_list.rb +1 -1
  8. data/lib/omise/charge.rb +12 -4
  9. data/lib/omise/customer.rb +3 -3
  10. data/lib/omise/dispute.rb +38 -0
  11. data/lib/omise/list.rb +1 -1
  12. data/lib/omise/recipient.rb +44 -0
  13. data/lib/omise/refund.rb +1 -1
  14. data/lib/omise/refund_list.rb +1 -1
  15. data/lib/omise/resource.rb +4 -4
  16. data/lib/omise/token.rb +2 -2
  17. data/lib/omise/transaction.rb +2 -2
  18. data/lib/omise/transfer.rb +24 -3
  19. data/lib/omise/util.rb +1 -1
  20. data/lib/omise/version.rb +1 -1
  21. data/omise.gemspec +3 -2
  22. data/test/fixtures/api.omise.co/disputes-get.json +22 -0
  23. data/test/fixtures/api.omise.co/disputes/closed-get.json +22 -0
  24. data/test/fixtures/api.omise.co/disputes/dspt_test_5089off452g5m5te7xs-get.json +12 -0
  25. data/test/fixtures/api.omise.co/disputes/dspt_test_5089off452g5m5te7xs-patch.json +12 -0
  26. data/test/fixtures/api.omise.co/disputes/open-get.json +22 -0
  27. data/test/fixtures/api.omise.co/disputes/pending-get.json +22 -0
  28. data/test/fixtures/api.omise.co/recipients-get.json +33 -0
  29. data/test/fixtures/api.omise.co/recipients-post.json +22 -0
  30. data/test/fixtures/api.omise.co/recipients/recp_test_50894vc13y8z4v51iuc-delete.json +6 -0
  31. data/test/fixtures/api.omise.co/recipients/recp_test_50894vc13y8z4v51iuc-get.json +22 -0
  32. data/test/fixtures/api.omise.co/recipients/recp_test_50894vc13y8z4v51iuc-patch.json +22 -0
  33. data/test/fixtures/api.omise.co/transfers-get.json +8 -0
  34. data/test/fixtures/api.omise.co/transfers-post.json +9 -1
  35. data/test/fixtures/api.omise.co/transfers/trsf_test_4yqacz8t3cbipcj766u-delete.json +6 -0
  36. data/test/fixtures/api.omise.co/transfers/trsf_test_4yqacz8t3cbipcj766u-get.json +8 -0
  37. data/test/fixtures/api.omise.co/transfers/trsf_test_4yqacz8t3cbipcj766u-patch.json +22 -0
  38. data/test/omise/test_dispute.rb +42 -0
  39. data/test/omise/test_recipient.rb +42 -0
  40. data/test/omise/test_token.rb +1 -1
  41. data/test/omise/test_transfer.rb +21 -0
  42. metadata +58 -12
  43. data/test/test_omise.rb +0 -7
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ac74ee13ddd25f59492be50022c44d1774f03a29
4
- data.tar.gz: c078bf5ac5d1f780c4d29c3148ba77343e31f6ed
3
+ metadata.gz: f6852ee1de623596c7e12062abde1d30c98b0385
4
+ data.tar.gz: ee2026f753f19c139f5a0b49754413ea0954f690
5
5
  SHA512:
6
- metadata.gz: 236389607f5d7d6fcc1d06b6515dc4fa0b953708fbebf906d3e55a6f0546e8c568cc8c6ab640dee67788750db70b937e271aa743e2220f12b4b7ca7cb6e53a12
7
- data.tar.gz: 16aa16a9d23ae834ea4ed9422d68e045fec145cf49a825f156f56ddb7cd02a3be5a01ebb9773f8786cfec764fa96daaaa4f96f5b8a5bae19887bbdc53759c46e
6
+ metadata.gz: 3e025390629469469ff2088c80335f693588969a868bb662adec2792fc90b34bbba1bdf653b44e611f52eee72f6eef1c134d04b072cf8bb4b8f9afe08fce95a1
7
+ data.tar.gz: d217731bafe539b88fee27b31b0985711af33aef2789eaf884b490d132670f2efacdcc79e19d71aefcaa53e4fa6122afb0c2f3ad525254a39cdd8630ba61d0c2
data/CHANGELOG.md ADDED
@@ -0,0 +1,23 @@
1
+ # Change Log
2
+
3
+ An [unreleased] version is not available on rubygems and is subject to changes and must not be considered final. Elements of unreleased list may be edited or removed at any time.
4
+
5
+ ## [unreleased]
6
+
7
+ - [Added] Add json dependency in the gemspec.
8
+
9
+ ## [0.1.1] 2015-01-19
10
+
11
+ - [Fixed] Fix a charge object is not able to retrieve its transaction object.
12
+
13
+ ## [0.1.0] 2015-01-19
14
+
15
+ - [Added] Add support for the Refund API.
16
+ - [Added] Add a test suite that can be run locally without the need for a network connection or to set Omise keys.
17
+ - [Added] Add a list method to retrieve a list of objects.
18
+ - [Changed] Move typecast and load_response methods into a Util module.
19
+ - [Removed] Remove the ability to retrieve a list by calling retrieve without arguments.
20
+
21
+ ## [0.0.1] - 2014-11-18
22
+
23
+ - Initial version.
data/README.md CHANGED
@@ -1,10 +1,12 @@
1
1
  # Omise Ruby Client
2
2
 
3
- [![Code Climate](https://codeclimate.com/github/omise/omise-ruby/badges/gpa.svg)](https://codeclimate.com/github/omise/omise-ruby)
3
+ [![CodeClimate](https://img.shields.io/codeclimate/github/omise/omise-ruby.svg?style=flat)](https://codeclimate.com/github/omise/omise-ruby)
4
+ ![CircleCI](https://img.shields.io/circleci/project/omise/omise-ruby.svg?style=flat)
5
+ [![Gem](https://img.shields.io/gem/v/omise.svg?style=flat)](https://rubygems.org/gems/omise)
4
6
 
5
7
  ## Installation
6
8
 
7
- Install using rubgems:
9
+ Installing via rubgems:
8
10
 
9
11
  ```ruby
10
12
  gem 'omise'
@@ -16,47 +18,56 @@ Or use the cutting-edge version by installing via github:
16
18
  gem 'omise', github: 'omise/omise-ruby'
17
19
  ```
18
20
 
19
- ## Examples
21
+ ## Requirements
20
22
 
21
- First configure your api key.
23
+ Requires ruby 1.9.2 or above, the rest-client and json gem.
24
+
25
+ ## Configuration
26
+
27
+ First configure your secret key:
22
28
 
23
29
  ```ruby
24
- Omise.api_key = "skey_test_4xa89ox4z4bcfrikkh2"
30
+ Omise.api_key = "skey_test_xxxxxxxxxxxxxxxxxxx"
25
31
  ```
26
32
 
27
- Then you're ready to go. Here's how to create customer:
33
+ If you need to use the Token API you also need to set your public key:
28
34
 
29
35
  ```ruby
30
- customer = Omise::Customer.create({
31
- description: "John Doe",
32
- email: "john.doe@example.com"
33
- })
34
-
35
- puts customer.attributes
36
- # {
37
- # "object" => "customer",
38
- # "id" => "...",
39
- # "livemode" => false,
40
- # "location" => "/customers/...",
41
- # "default_card" => nil,
42
- # "email" => "john.doe@example.com",
43
- # "description" => "John Doe",
44
- # "created" => "2014-09-05T09:03:05Z",
45
- # "cards" => {
46
- # "object": "list",
47
- # ...
48
- # }
49
- # }
36
+ Omise.vault_key = "pkey_test_xxxxxxxxxxxxxxxxxxx"
50
37
  ```
51
38
 
52
- Then find, update and destroy that customer.
39
+ With this set you'll be able to retrieve tokens or create new ones.
53
40
 
54
- ```ruby
55
- customer = Omise::Customer.find("cust_test_4xald9y2ttb5mvplw0c")
41
+ However we recommend using [Omise.js](https://gitub.com/omise/omise.js) to
42
+ create tokens. When creating a token server side you'll need card data
43
+ transiting to and from your server and this requires that your organization be
44
+ PCI compliant.
45
+
46
+ ## Quick Start
56
47
 
57
- customer.update description: "John W. Doe"
58
- customer.description # => "John W. Doe"
48
+ After you have implemented [Omise.js](https://gitub.com/omise/omise.js) on your
49
+ frontend you can charge the card by passing the token into the `card` attribute.
59
50
 
60
- customer.destroy
61
- customer.destroyed? # => true
51
+ ```ruby
52
+ # Charge 1000.00 THB
53
+ charge = Omise::Charge.create({
54
+ amount: 1_000_00,
55
+ currency: "thb",
56
+ card: params[:omise_token]
57
+ })
58
+
59
+ if charge.captured
60
+ # handle success
61
+ puts "thanks"
62
+ else
63
+ # handle failure
64
+ raise charge.failure_code
65
+ end
62
66
  ```
67
+
68
+ You can check the complete documentation at
69
+ [docs.omise.co](https://docs.omise.co/).
70
+
71
+ ## Development
72
+
73
+ The test suite can be run with `bundle exec rake test`.
data/lib/omise/all.rb CHANGED
@@ -3,6 +3,8 @@ require "omise/balance"
3
3
  require "omise/card"
4
4
  require "omise/charge"
5
5
  require "omise/customer"
6
+ require "omise/dispute"
7
+ require "omise/recipient"
6
8
  require "omise/refund"
7
9
  require "omise/token"
8
10
  require "omise/transaction"
@@ -0,0 +1,6 @@
1
+ require "omise/object"
2
+
3
+ module Omise
4
+ class BankAccount < OmiseObject
5
+ end
6
+ end
data/lib/omise/card.rb CHANGED
@@ -5,7 +5,7 @@ module Omise
5
5
  self.endpoint = "/cards"
6
6
 
7
7
  def reload(attributes = {})
8
- assign_attributes resource(attributes).get
8
+ assign_attributes resource(attributes).get(attributes)
9
9
  end
10
10
 
11
11
  def update(attributes = {})
@@ -10,7 +10,7 @@ module Omise
10
10
  end
11
11
 
12
12
  def retrieve(id, attributes = {})
13
- Card.new self.class.resource(location(id), attributes).get
13
+ Card.new self.class.resource(location(id), attributes).get(attributes)
14
14
  end
15
15
 
16
16
  def create(attributes = {})
data/lib/omise/charge.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  require "omise/object"
2
2
  require "omise/list"
3
3
  require "omise/customer"
4
+ require "omise/dispute"
4
5
  require "omise/refund_list"
5
6
  require "omise/transaction"
6
7
 
@@ -9,11 +10,11 @@ module Omise
9
10
  self.endpoint = "/charges"
10
11
 
11
12
  def self.retrieve(id, attributes = {})
12
- new resource(location(id), attributes).get
13
+ new resource(location(id), attributes).get(attributes)
13
14
  end
14
15
 
15
16
  def self.list(attributes = {})
16
- List.new resource(location, attributes).get
17
+ List.new resource(location, attributes).get(attributes)
17
18
  end
18
19
 
19
20
  def self.create(attributes = {})
@@ -21,7 +22,7 @@ module Omise
21
22
  end
22
23
 
23
24
  def reload(attributes = {})
24
- assign_attributes resource(attributes).get
25
+ assign_attributes resource(attributes).get(attributes)
25
26
  end
26
27
 
27
28
  def update(attributes = {})
@@ -34,6 +35,12 @@ module Omise
34
35
  end
35
36
  end
36
37
 
38
+ def dispute(options = {})
39
+ if @attributes["dispute"]
40
+ @dispute ||= Dispute.retrieve(@attributes["dispute"], options)
41
+ end
42
+ end
43
+
37
44
  def transaction(options = {})
38
45
  if @attributes["transaction"]
39
46
  @transaction ||= Transaction.retrieve(@attributes["transaction"], options)
@@ -47,8 +54,9 @@ module Omise
47
54
  private
48
55
 
49
56
  def cleanup!
50
- @refunds = nil
51
57
  @customer = nil
58
+ @dispute = nil
59
+ @refunds = nil
52
60
  @transaction = nil
53
61
  end
54
62
  end
@@ -7,11 +7,11 @@ module Omise
7
7
  self.endpoint = "/customers"
8
8
 
9
9
  def self.retrieve(id = nil, attributes = {})
10
- new resource(location(id), attributes).get
10
+ new resource(location(id), attributes).get(attributes)
11
11
  end
12
12
 
13
13
  def self.list(attributes = {})
14
- List.new resource(location, attributes).get
14
+ List.new resource(location, attributes).get(attributes)
15
15
  end
16
16
 
17
17
  def self.create(attributes = {})
@@ -19,7 +19,7 @@ module Omise
19
19
  end
20
20
 
21
21
  def reload(attributes = {})
22
- assign_attributes resource(attributes).get
22
+ assign_attributes resource(attributes).get(attributes)
23
23
  end
24
24
 
25
25
  def update(attributes = {})
@@ -0,0 +1,38 @@
1
+ require "omise/object"
2
+ require "omise/charge"
3
+ require "omise/list"
4
+
5
+ module Omise
6
+ class Dispute < OmiseObject
7
+ self.endpoint = "/disputes"
8
+
9
+ def self.list(attributes = {})
10
+ status = attributes.delete(:status)
11
+ List.new resource(location(status), attributes).get(attributes)
12
+ end
13
+
14
+ def self.retrieve(id = nil, attributes = {})
15
+ new resource(location(id), attributes).get(attributes)
16
+ end
17
+
18
+ def reload(attributes = {})
19
+ assign_attributes resource(attributes).get(attributes)
20
+ end
21
+
22
+ def update(attributes = {})
23
+ assign_attributes resource(attributes).patch(attributes)
24
+ end
25
+
26
+ def charge(options = {})
27
+ if @attributes["charge"]
28
+ @charge ||= Charge.retrieve(@attributes["charge"], options)
29
+ end
30
+ end
31
+
32
+ private
33
+
34
+ def cleanup!
35
+ @charge = nil
36
+ end
37
+ end
38
+ end
data/lib/omise/list.rb CHANGED
@@ -11,7 +11,7 @@ module Omise
11
11
  end
12
12
 
13
13
  def reload(attributes = {})
14
- assign_attributes resource(attributes).get do
14
+ assign_attributes resource(attributes).get(attributes) do
15
15
  setup_data
16
16
  end
17
17
  end
@@ -0,0 +1,44 @@
1
+ require "omise/object"
2
+ require "omise/bank_account"
3
+
4
+ module Omise
5
+ class Recipient < OmiseObject
6
+ self.endpoint = "/recipients"
7
+
8
+ def self.retrieve(id, attributes = {})
9
+ new resource(location(id), attributes).get(attributes)
10
+ end
11
+
12
+ def self.list(attributes = {})
13
+ List.new resource(location, attributes).get(attributes)
14
+ end
15
+
16
+ def self.create(attributes = {})
17
+ new resource(location, attributes).post(attributes)
18
+ end
19
+
20
+ def reload(attributes = {})
21
+ assign_attributes resource(attributes).get(attributes)
22
+ end
23
+
24
+ def update(attributes = {})
25
+ assign_attributes resource(attributes).patch(attributes)
26
+ end
27
+
28
+ def destroy(attributes = {})
29
+ assign_attributes resource(attributes).delete
30
+ end
31
+
32
+ def bank_account
33
+ if @attributes["bank_account"]
34
+ @bank_account ||= BankAccount.new(@attributes["bank_account"])
35
+ end
36
+ end
37
+
38
+ private
39
+
40
+ def cleanup!
41
+ @bank_account = nil
42
+ end
43
+ end
44
+ end
data/lib/omise/refund.rb CHANGED
@@ -7,7 +7,7 @@ module Omise
7
7
  self.endpoint = "/refunds"
8
8
 
9
9
  def reload(attributes = {})
10
- assign_attributes resource(attributes).get
10
+ assign_attributes resource(attributes).get(attributes)
11
11
  end
12
12
 
13
13
  def charge(options = {})
@@ -13,7 +13,7 @@ module Omise
13
13
  end
14
14
 
15
15
  def retrieve(id, attributes = {})
16
- Refund.new self.class.resource(location(id), attributes).get
16
+ Refund.new self.class.resource(location(id), attributes).get(attributes)
17
17
  end
18
18
  end
19
19
  end
@@ -24,15 +24,15 @@ module Omise
24
24
  })
25
25
  end
26
26
 
27
- def get
28
- @resource.get { |r| Omise::Util.load_response(r) }
27
+ def get(attributes = {})
28
+ @resource.get(params: attributes) { |r| Omise::Util.load_response(r) }
29
29
  end
30
30
 
31
- def patch(attributes)
31
+ def patch(attributes = {})
32
32
  @resource.patch(attributes) { |r| Omise::Util.load_response(r) }
33
33
  end
34
34
 
35
- def post(attributes)
35
+ def post(attributes = {})
36
36
  @resource.post(attributes) { |r| Omise::Util.load_response(r) }
37
37
  end
38
38
 
data/lib/omise/token.rb CHANGED
@@ -8,7 +8,7 @@ module Omise
8
8
  extend Vault
9
9
 
10
10
  def self.retrieve(id, attributes = {})
11
- new resource(location(id), attributes).get
11
+ new resource(location(id), attributes).get(attributes)
12
12
  end
13
13
 
14
14
  def self.create(attributes = {})
@@ -16,7 +16,7 @@ module Omise
16
16
  end
17
17
 
18
18
  def reload(attributes = {})
19
- assign_attributes resource(attributes).get
19
+ assign_attributes resource(attributes).get(attributes)
20
20
  end
21
21
 
22
22
  def self.preprocess_attributes!(attributes)
@@ -6,11 +6,11 @@ module Omise
6
6
  self.endpoint = "/transactions"
7
7
 
8
8
  def self.retrieve(id = nil, attributes = {})
9
- new resource(location(id), attributes).get
9
+ new resource(location(id), attributes).get(attributes)
10
10
  end
11
11
 
12
12
  def self.list(attributes = {})
13
- List.new resource(location, attributes).get
13
+ List.new resource(location, attributes).get(attributes)
14
14
  end
15
15
  end
16
16
  end
@@ -1,5 +1,7 @@
1
1
  require "omise/object"
2
+ require "omise/bank_account"
2
3
  require "omise/list"
4
+ require "omise/recipient"
3
5
 
4
6
  module Omise
5
7
  class Transfer < OmiseObject
@@ -10,15 +12,15 @@ module Omise
10
12
  end
11
13
 
12
14
  def self.retrieve(id, attributes = {})
13
- new resource(location(id), attributes).get
15
+ new resource(location(id), attributes).get(attributes)
14
16
  end
15
17
 
16
18
  def self.list(attributes = {})
17
- List.new resource(location, attributes).get
19
+ List.new resource(location, attributes).get(attributes)
18
20
  end
19
21
 
20
22
  def reload(attributes = {})
21
- assign_attributes resource(attributes).get
23
+ assign_attributes resource(attributes).get(attributes)
22
24
  end
23
25
 
24
26
  def update(attributes = {})
@@ -28,5 +30,24 @@ module Omise
28
30
  def destroy(attributes = {})
29
31
  assign_attributes resource(attributes).delete
30
32
  end
33
+
34
+ def recipient
35
+ if @attributes["recipient"]
36
+ @recipient ||= Recipient.retrieve(@attributes["recipient"])
37
+ end
38
+ end
39
+
40
+ def bank_account
41
+ if @attributes["bank_account"]
42
+ @bank_account ||= BankAccount.new(@attributes["bank_account"])
43
+ end
44
+ end
45
+
46
+ private
47
+
48
+ def cleanup!
49
+ @bank_account = nil
50
+ @recipient = nil
51
+ end
31
52
  end
32
53
  end
data/lib/omise/util.rb CHANGED
@@ -7,7 +7,7 @@ module Omise
7
7
  module Util module_function
8
8
  def typecast(object)
9
9
  klass = begin
10
- const_get(object["object"].capitalize)
10
+ Omise.const_get(object["object"].capitalize)
11
11
  rescue NameError
12
12
  OmiseObject
13
13
  end
data/lib/omise/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Omise
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.4"
3
3
  end
data/omise.gemspec CHANGED
@@ -18,8 +18,9 @@ Gem::Specification.new do |spec|
18
18
  spec.require_paths = ["lib"]
19
19
 
20
20
  spec.add_dependency "rest-client", "~> 1.7.2"
21
+ spec.add_dependency "json", "~> 1.8.1"
21
22
 
22
- spec.add_development_dependency "bundler", "~> 1.7"
23
- spec.add_development_dependency "rake", "~> 10.0"
23
+ spec.add_development_dependency "bundler"
24
+ spec.add_development_dependency "rake"
24
25
  spec.add_development_dependency "minitest", "~> 5.4.2"
25
26
  end
@@ -0,0 +1,22 @@
1
+ {
2
+ "object": "list",
3
+ "from": "1970-01-01T07:00:00+07:00",
4
+ "to": "2015-06-02T17:38:43+07:00",
5
+ "offset": 0,
6
+ "limit": 20,
7
+ "total": 1,
8
+ "data": [
9
+ {
10
+ "object": "dispute",
11
+ "id": "dspt_test_5089off452g5m5te7xs",
12
+ "livemode": false,
13
+ "location": "/disputes/dspt_test_5089off452g5m5te7xs",
14
+ "amount": 100000,
15
+ "currency": "thb",
16
+ "status": "open",
17
+ "message": null,
18
+ "charge": "chrg_test_5089odjlzg9j7tw4i1q",
19
+ "created": "2015-06-02T10:22:32Z"
20
+ }
21
+ ]
22
+ }
@@ -0,0 +1,22 @@
1
+ {
2
+ "object": "list",
3
+ "from": "1970-01-01T07:00:00+07:00",
4
+ "to": "2015-06-02T17:40:52+07:00",
5
+ "offset": 0,
6
+ "limit": 20,
7
+ "total": 1,
8
+ "data": [
9
+ {
10
+ "object": "dispute",
11
+ "id": "dspt_test_5089off452g5m5te7xs",
12
+ "livemode": false,
13
+ "location": "/disputes/dspt_test_5089off452g5m5te7xs",
14
+ "amount": 100000,
15
+ "currency": "thb",
16
+ "status": "won",
17
+ "message": "This customer has send us his authorization to withdraw the fund from his card ....",
18
+ "charge": "chrg_test_5089odjlzg9j7tw4i1q",
19
+ "created": "2015-06-02T10:22:32Z"
20
+ }
21
+ ]
22
+ }
@@ -0,0 +1,12 @@
1
+ {
2
+ "object": "dispute",
3
+ "id": "dspt_test_5089off452g5m5te7xs",
4
+ "livemode": false,
5
+ "location": "/disputes/dspt_test_5089off452g5m5te7xs",
6
+ "amount": 100000,
7
+ "currency": "thb",
8
+ "status": "open",
9
+ "message": null,
10
+ "charge": "chrg_test_5089odjlzg9j7tw4i1q",
11
+ "created": "2015-06-02T10:22:32Z"
12
+ }
@@ -0,0 +1,12 @@
1
+ {
2
+ "object": "dispute",
3
+ "id": "dspt_test_5089off452g5m5te7xs",
4
+ "livemode": false,
5
+ "location": "/disputes/dspt_test_5089off452g5m5te7xs",
6
+ "amount": 100000,
7
+ "currency": "thb",
8
+ "status": "open",
9
+ "message": "Your dispute message",
10
+ "charge": "chrg_test_4yq7duw15p9hdrjp8oq",
11
+ "created": "2015-06-02T10:22:32Z"
12
+ }
@@ -0,0 +1,22 @@
1
+ {
2
+ "object": "list",
3
+ "from": "1970-01-01T07:00:00+07:00",
4
+ "to": "2015-06-02T17:38:43+07:00",
5
+ "offset": 0,
6
+ "limit": 20,
7
+ "total": 1,
8
+ "data": [
9
+ {
10
+ "object": "dispute",
11
+ "id": "dspt_test_5089off452g5m5te7xs",
12
+ "livemode": false,
13
+ "location": "/disputes/dspt_test_5089off452g5m5te7xs",
14
+ "amount": 100000,
15
+ "currency": "thb",
16
+ "status": "open",
17
+ "message": null,
18
+ "charge": "chrg_test_5089odjlzg9j7tw4i1q",
19
+ "created": "2015-06-02T10:22:32Z"
20
+ }
21
+ ]
22
+ }
@@ -0,0 +1,22 @@
1
+ {
2
+ "object": "list",
3
+ "from": "1970-01-01T07:00:00+07:00",
4
+ "to": "2015-06-02T17:39:28+07:00",
5
+ "offset": 0,
6
+ "limit": 20,
7
+ "total": 1,
8
+ "data": [
9
+ {
10
+ "object": "dispute",
11
+ "id": "dspt_test_5089off452g5m5te7xs",
12
+ "livemode": false,
13
+ "location": "/disputes/dspt_test_5089off452g5m5te7xs",
14
+ "amount": 100000,
15
+ "currency": "thb",
16
+ "status": "pending",
17
+ "message": "This customer has send us his authorization to withdraw the fund from his card ....",
18
+ "charge": "chrg_test_5089odjlzg9j7tw4i1q",
19
+ "created": "2015-06-02T10:22:32Z"
20
+ }
21
+ ]
22
+ }
@@ -0,0 +1,33 @@
1
+ {
2
+ "object": "list",
3
+ "from": "1970-01-01T07:00:00+07:00",
4
+ "to": "2015-06-02T17:48:28+07:00",
5
+ "offset": 0,
6
+ "limit": 20,
7
+ "total": 1,
8
+ "data": [
9
+ {
10
+ "object": "recipient",
11
+ "id": "recp_test_50894vc13y8z4v51iuc",
12
+ "livemode": false,
13
+ "location": "/recipients/recp_test_50894vc13y8z4v51iuc",
14
+ "verified": true,
15
+ "active": true,
16
+ "name": "john.doe@example.com",
17
+ "email": "john.doe@example.com",
18
+ "description": "Default recipient",
19
+ "type": "individual",
20
+ "tax_id": "",
21
+ "bank_account": {
22
+ "object": "bank_account",
23
+ "brand": "test",
24
+ "last_digits": "6789",
25
+ "name": "JOHN DOE",
26
+ "created": "2015-06-02T09:26:59Z"
27
+ },
28
+ "failure_code": null,
29
+ "created": "2015-06-02T09:26:59Z"
30
+ }
31
+ ],
32
+ "location": "/recipients"
33
+ }
@@ -0,0 +1,22 @@
1
+ {
2
+ "object": "recipient",
3
+ "id": "recp_test_50894vc13y8z4v51iuc",
4
+ "livemode": false,
5
+ "location": "/recipients/recp_test_50894vc13y8z4v51iuc",
6
+ "verified": true,
7
+ "active": true,
8
+ "name": "john.doe@example.com",
9
+ "email": "john.doe@example.com",
10
+ "description": "Default recipient",
11
+ "type": "individual",
12
+ "tax_id": "",
13
+ "bank_account": {
14
+ "object": "bank_account",
15
+ "brand": "test",
16
+ "last_digits": "6789",
17
+ "name": "JOHN DOE",
18
+ "created": "2015-06-02T09:26:59Z"
19
+ },
20
+ "failure_code": null,
21
+ "created": "2015-06-02T09:26:59Z"
22
+ }
@@ -0,0 +1,6 @@
1
+ {
2
+ "object": "recipient",
3
+ "id": "recp_test_50894vc13y8z4v51iuc",
4
+ "livemode": false,
5
+ "deleted": true
6
+ }
@@ -0,0 +1,22 @@
1
+ {
2
+ "object": "recipient",
3
+ "id": "recp_test_50894vc13y8z4v51iuc",
4
+ "livemode": false,
5
+ "location": "/recipients/recp_test_50894vc13y8z4v51iuc",
6
+ "verified": true,
7
+ "active": true,
8
+ "name": "john.doe@example.com",
9
+ "email": "john.doe@example.com",
10
+ "description": "Default recipient",
11
+ "type": "individual",
12
+ "tax_id": "",
13
+ "bank_account": {
14
+ "object": "bank_account",
15
+ "brand": "test",
16
+ "last_digits": "6789",
17
+ "name": "JOHN DOE",
18
+ "created": "2015-06-02T09:26:59Z"
19
+ },
20
+ "failure_code": null,
21
+ "created": "2015-06-02T09:26:59Z"
22
+ }
@@ -0,0 +1,22 @@
1
+ {
2
+ "object": "recipient",
3
+ "id": "recp_test_50894vc13y8z4v51iuc",
4
+ "livemode": false,
5
+ "location": "/recipients/recp_test_50894vc13y8z4v51iuc",
6
+ "verified": true,
7
+ "active": true,
8
+ "name": "john@doe.com",
9
+ "email": "john@doe.com",
10
+ "description": "Default recipient",
11
+ "type": "individual",
12
+ "tax_id": "",
13
+ "bank_account": {
14
+ "object": "bank_account",
15
+ "brand": "test",
16
+ "last_digits": "6789",
17
+ "name": "JOHN DOE",
18
+ "created": "2015-06-02T09:26:59Z"
19
+ },
20
+ "failure_code": null,
21
+ "created": "2015-06-02T09:26:59Z"
22
+ }
@@ -18,6 +18,14 @@
18
18
  "failure_code": null,
19
19
  "failure_message": null,
20
20
  "transaction": "trxn_test_4yqafnvlztbf3908vs1",
21
+ "recipient": "recp_test_50894vc13y8z4v51iuc",
22
+ "bank_account": {
23
+ "object": "bank_account",
24
+ "brand": "test",
25
+ "last_digits": "6789",
26
+ "name": "JOHN DOE",
27
+ "created": "2015-06-02T09:26:59Z"
28
+ },
21
29
  "created": "2015-01-15T10:04:47Z"
22
30
  }
23
31
  ]
@@ -9,6 +9,14 @@
9
9
  "currency": "thb",
10
10
  "failure_code": null,
11
11
  "failure_message": null,
12
- "transaction": null,
12
+ "transaction": "trxn_test_4yqafnvlztbf3908vs1",
13
+ "recipient": "recp_test_50894vc13y8z4v51iuc",
14
+ "bank_account": {
15
+ "object": "bank_account",
16
+ "brand": "test",
17
+ "last_digits": "6789",
18
+ "name": "JOHN DOE",
19
+ "created": "2015-06-02T09:26:59Z"
20
+ },
13
21
  "created": "2015-01-15T10:04:47Z"
14
22
  }
@@ -0,0 +1,6 @@
1
+ {
2
+ "object": "transfer",
3
+ "id": "trsf_test_4yqacz8t3cbipcj766u",
4
+ "livemode": false,
5
+ "deleted": true
6
+ }
@@ -10,5 +10,13 @@
10
10
  "failure_code": null,
11
11
  "failure_message": null,
12
12
  "transaction": "trxn_test_4yqafnvlztbf3908vs1",
13
+ "recipient": "recp_test_50894vc13y8z4v51iuc",
14
+ "bank_account": {
15
+ "object": "bank_account",
16
+ "brand": "test",
17
+ "last_digits": "6789",
18
+ "name": "JOHN DOE",
19
+ "created": "2015-06-02T09:26:59Z"
20
+ },
13
21
  "created": "2015-01-15T10:04:47Z"
14
22
  }
@@ -0,0 +1,22 @@
1
+ {
2
+ "object": "transfer",
3
+ "id": "trsf_test_4yqacz8t3cbipcj766u",
4
+ "livemode": false,
5
+ "location": "/transfers/trsf_test_4yqacz8t3cbipcj766u",
6
+ "sent": true,
7
+ "paid": true,
8
+ "amount": 192189,
9
+ "currency": "thb",
10
+ "failure_code": null,
11
+ "failure_message": null,
12
+ "transaction": "trxn_test_4yqafnvlztbf3908vs1",
13
+ "recipient": "recp_test_50894vc13y8z4v51iuc",
14
+ "bank_account": {
15
+ "object": "bank_account",
16
+ "brand": "test",
17
+ "last_digits": "6789",
18
+ "name": "JOHN DOE",
19
+ "created": "2015-06-02T09:26:59Z"
20
+ },
21
+ "created": "2015-01-15T10:04:47Z"
22
+ }
@@ -0,0 +1,42 @@
1
+ require "support"
2
+
3
+ class TestDispute < Minitest::Test
4
+ def setup
5
+ @dispute = Omise::Dispute.retrieve("dspt_test_5089off452g5m5te7xs")
6
+ end
7
+
8
+ def test_that_we_can_list_all_disputes
9
+ disputes = Omise::Dispute.list
10
+
11
+ assert_instance_of Omise::List, disputes
12
+ end
13
+
14
+ def test_that_we_can_list_all_open_disputes
15
+ disputes = Omise::Dispute.list(status: :open)
16
+
17
+ assert_instance_of Omise::List, disputes
18
+ end
19
+
20
+ def test_that_we_can_list_all_pending_disputes
21
+ disputes = Omise::Dispute.list(status: :pending)
22
+
23
+ assert_instance_of Omise::List, disputes
24
+ end
25
+
26
+ def test_that_we_can_list_all_closed_disputes
27
+ disputes = Omise::Dispute.list(status: :closed)
28
+
29
+ assert_instance_of Omise::List, disputes
30
+ end
31
+
32
+ def test_that_we_can_retrieve_a_dispute
33
+ assert_instance_of Omise::Dispute, @dispute
34
+ assert_equal "dspt_test_5089off452g5m5te7xs", @dispute.id
35
+ end
36
+
37
+ def test_that_we_can_update_a_dispute
38
+ @dispute.update(message: "Your dispute message")
39
+
40
+ assert_equal @dispute.message, "Your dispute message"
41
+ end
42
+ end
@@ -0,0 +1,42 @@
1
+ require "support"
2
+
3
+ class TestRecipient < Minitest::Test
4
+ def setup
5
+ @recipient = Omise::Recipient.retrieve("recp_test_50894vc13y8z4v51iuc")
6
+ end
7
+
8
+ def test_that_we_can_retrieve_a_recipient
9
+ assert_instance_of Omise::Recipient, @recipient
10
+ assert_equal "recp_test_50894vc13y8z4v51iuc", @recipient.id
11
+ end
12
+
13
+ def test_that_we_can_list_all_recipients
14
+ recipients = Omise::Recipient.list
15
+
16
+ assert_instance_of Omise::List, recipients
17
+ end
18
+
19
+ def test_that_we_can_update_a_recipient
20
+ @recipient.update(email: "john@doe.com")
21
+
22
+ assert_equal "john@doe.com", @recipient.email
23
+ end
24
+
25
+ def test_that_we_can_reload_a_recipient
26
+ @recipient.attributes.taint
27
+ @recipient.reload
28
+
29
+ refute @recipient.attributes.tainted?
30
+ end
31
+
32
+ def test_that_we_can_destroy_a_recipient
33
+ @recipient.destroy
34
+
35
+ assert @recipient.deleted
36
+ assert @recipient.destroyed?
37
+ end
38
+
39
+ def test_that_a_recipient_has_a_bank_account
40
+ assert_instance_of Omise::BankAccount, @recipient.bank_account
41
+ end
42
+ end
@@ -6,7 +6,7 @@ class TestToken < Minitest::Test
6
6
  end
7
7
 
8
8
  def test_that_we_can_create_a_token
9
- token = Omise::Token.create({
9
+ token = Omise::Token.create(card: {
10
10
  name: "JOHN DOE",
11
11
  number: "4242424242424242",
12
12
  expiration_month: "1",
@@ -16,9 +16,30 @@ class TestTransfer < Minitest::Test
16
16
  assert_equal "trsf_test_4yqacz8t3cbipcj766u", @transfer.id
17
17
  end
18
18
 
19
+ def test_that_we_can_update_a_transfer
20
+ @transfer.update(amount: 192189)
21
+
22
+ assert_equal 192189, @transfer.amount
23
+ end
24
+
25
+ def test_that_we_can_destroy_a_transfer
26
+ @transfer.destroy
27
+
28
+ assert @transfer.deleted
29
+ assert @transfer.destroyed?
30
+ end
31
+
19
32
  def test_that_we_can_list_all_transfer
20
33
  transfers = Omise::Transfer.list
21
34
 
22
35
  assert_instance_of Omise::List, transfers
23
36
  end
37
+
38
+ def test_that_a_transfer_has_a_recipient
39
+ assert_instance_of Omise::Recipient, @transfer.recipient
40
+ end
41
+
42
+ def test_that_a_transfer_has_a_bank_account
43
+ assert_instance_of Omise::BankAccount, @transfer.bank_account
44
+ end
24
45
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: omise
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robin Clart
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-01-19 00:00:00.000000000 Z
11
+ date: 2015-06-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rest-client
@@ -25,33 +25,47 @@ dependencies:
25
25
  - !ruby/object:Gem::Version
26
26
  version: 1.7.2
27
27
  - !ruby/object:Gem::Dependency
28
- name: bundler
28
+ name: json
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - ~>
32
32
  - !ruby/object:Gem::Version
33
- version: '1.7'
34
- type: :development
33
+ version: 1.8.1
34
+ type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - ~>
39
39
  - !ruby/object:Gem::Version
40
- version: '1.7'
40
+ version: 1.8.1
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: rake
43
57
  requirement: !ruby/object:Gem::Requirement
44
58
  requirements:
45
- - - ~>
59
+ - - '>='
46
60
  - !ruby/object:Gem::Version
47
- version: '10.0'
61
+ version: '0'
48
62
  type: :development
49
63
  prerelease: false
50
64
  version_requirements: !ruby/object:Gem::Requirement
51
65
  requirements:
52
- - - ~>
66
+ - - '>='
53
67
  - !ruby/object:Gem::Version
54
- version: '10.0'
68
+ version: '0'
55
69
  - !ruby/object:Gem::Dependency
56
70
  name: minitest
57
71
  requirement: !ruby/object:Gem::Requirement
@@ -74,6 +88,7 @@ extensions: []
74
88
  extra_rdoc_files: []
75
89
  files:
76
90
  - .gitignore
91
+ - CHANGELOG.md
77
92
  - Gemfile
78
93
  - LICENSE.txt
79
94
  - README.md
@@ -84,14 +99,17 @@ files:
84
99
  - lib/omise/all.rb
85
100
  - lib/omise/attributes.rb
86
101
  - lib/omise/balance.rb
102
+ - lib/omise/bank_account.rb
87
103
  - lib/omise/card.rb
88
104
  - lib/omise/card_list.rb
89
105
  - lib/omise/charge.rb
90
106
  - lib/omise/config.rb
91
107
  - lib/omise/customer.rb
108
+ - lib/omise/dispute.rb
92
109
  - lib/omise/error.rb
93
110
  - lib/omise/list.rb
94
111
  - lib/omise/object.rb
112
+ - lib/omise/recipient.rb
95
113
  - lib/omise/refund.rb
96
114
  - lib/omise/refund_list.rb
97
115
  - lib/omise/resource.rb
@@ -125,13 +143,26 @@ files:
125
143
  - test/fixtures/api.omise.co/customers/cust_test_4yq6txdpfadhbaqnwp3/cards/card_test_4yq6tuucl9h4erukfl0-delete.json
126
144
  - test/fixtures/api.omise.co/customers/cust_test_4yq6txdpfadhbaqnwp3/cards/card_test_4yq6tuucl9h4erukfl0-get.json
127
145
  - test/fixtures/api.omise.co/customers/cust_test_4yq6txdpfadhbaqnwp3/cards/card_test_4yq6tuucl9h4erukfl0-patch.json
146
+ - test/fixtures/api.omise.co/disputes-get.json
147
+ - test/fixtures/api.omise.co/disputes/closed-get.json
148
+ - test/fixtures/api.omise.co/disputes/dspt_test_5089off452g5m5te7xs-get.json
149
+ - test/fixtures/api.omise.co/disputes/dspt_test_5089off452g5m5te7xs-patch.json
150
+ - test/fixtures/api.omise.co/disputes/open-get.json
151
+ - test/fixtures/api.omise.co/disputes/pending-get.json
152
+ - test/fixtures/api.omise.co/recipients-get.json
153
+ - test/fixtures/api.omise.co/recipients-post.json
154
+ - test/fixtures/api.omise.co/recipients/recp_test_50894vc13y8z4v51iuc-delete.json
155
+ - test/fixtures/api.omise.co/recipients/recp_test_50894vc13y8z4v51iuc-get.json
156
+ - test/fixtures/api.omise.co/recipients/recp_test_50894vc13y8z4v51iuc-patch.json
128
157
  - test/fixtures/api.omise.co/transactions-get.json
129
158
  - test/fixtures/api.omise.co/transactions/trxn_test_4yq7duwb9jts1vxgqua-get.json
130
159
  - test/fixtures/api.omise.co/transactions/trxn_test_4yqafnvlztbf3908vs1-get.json
131
160
  - test/fixtures/api.omise.co/transactions/trxn_test_4yqmv79fzpy0gmz5mmq-get.json
132
161
  - test/fixtures/api.omise.co/transfers-get.json
133
162
  - test/fixtures/api.omise.co/transfers-post.json
163
+ - test/fixtures/api.omise.co/transfers/trsf_test_4yqacz8t3cbipcj766u-delete.json
134
164
  - test/fixtures/api.omise.co/transfers/trsf_test_4yqacz8t3cbipcj766u-get.json
165
+ - test/fixtures/api.omise.co/transfers/trsf_test_4yqacz8t3cbipcj766u-patch.json
135
166
  - test/fixtures/vault.omise.co/tokens-post.json
136
167
  - test/fixtures/vault.omise.co/tokens/tokn_test_4yq8lbecl0q6dsjzxr5-get.json
137
168
  - test/omise/test_account.rb
@@ -139,12 +170,13 @@ files:
139
170
  - test/omise/test_card.rb
140
171
  - test/omise/test_charge.rb
141
172
  - test/omise/test_customer.rb
173
+ - test/omise/test_dispute.rb
174
+ - test/omise/test_recipient.rb
142
175
  - test/omise/test_refund.rb
143
176
  - test/omise/test_token.rb
144
177
  - test/omise/test_transaction.rb
145
178
  - test/omise/test_transfer.rb
146
179
  - test/support.rb
147
- - test/test_omise.rb
148
180
  homepage: https://www.omise.co/
149
181
  licenses:
150
182
  - MIT
@@ -191,13 +223,26 @@ test_files:
191
223
  - test/fixtures/api.omise.co/customers/cust_test_4yq6txdpfadhbaqnwp3/cards/card_test_4yq6tuucl9h4erukfl0-delete.json
192
224
  - test/fixtures/api.omise.co/customers/cust_test_4yq6txdpfadhbaqnwp3/cards/card_test_4yq6tuucl9h4erukfl0-get.json
193
225
  - test/fixtures/api.omise.co/customers/cust_test_4yq6txdpfadhbaqnwp3/cards/card_test_4yq6tuucl9h4erukfl0-patch.json
226
+ - test/fixtures/api.omise.co/disputes-get.json
227
+ - test/fixtures/api.omise.co/disputes/closed-get.json
228
+ - test/fixtures/api.omise.co/disputes/dspt_test_5089off452g5m5te7xs-get.json
229
+ - test/fixtures/api.omise.co/disputes/dspt_test_5089off452g5m5te7xs-patch.json
230
+ - test/fixtures/api.omise.co/disputes/open-get.json
231
+ - test/fixtures/api.omise.co/disputes/pending-get.json
232
+ - test/fixtures/api.omise.co/recipients-get.json
233
+ - test/fixtures/api.omise.co/recipients-post.json
234
+ - test/fixtures/api.omise.co/recipients/recp_test_50894vc13y8z4v51iuc-delete.json
235
+ - test/fixtures/api.omise.co/recipients/recp_test_50894vc13y8z4v51iuc-get.json
236
+ - test/fixtures/api.omise.co/recipients/recp_test_50894vc13y8z4v51iuc-patch.json
194
237
  - test/fixtures/api.omise.co/transactions-get.json
195
238
  - test/fixtures/api.omise.co/transactions/trxn_test_4yq7duwb9jts1vxgqua-get.json
196
239
  - test/fixtures/api.omise.co/transactions/trxn_test_4yqafnvlztbf3908vs1-get.json
197
240
  - test/fixtures/api.omise.co/transactions/trxn_test_4yqmv79fzpy0gmz5mmq-get.json
198
241
  - test/fixtures/api.omise.co/transfers-get.json
199
242
  - test/fixtures/api.omise.co/transfers-post.json
243
+ - test/fixtures/api.omise.co/transfers/trsf_test_4yqacz8t3cbipcj766u-delete.json
200
244
  - test/fixtures/api.omise.co/transfers/trsf_test_4yqacz8t3cbipcj766u-get.json
245
+ - test/fixtures/api.omise.co/transfers/trsf_test_4yqacz8t3cbipcj766u-patch.json
201
246
  - test/fixtures/vault.omise.co/tokens-post.json
202
247
  - test/fixtures/vault.omise.co/tokens/tokn_test_4yq8lbecl0q6dsjzxr5-get.json
203
248
  - test/omise/test_account.rb
@@ -205,10 +250,11 @@ test_files:
205
250
  - test/omise/test_card.rb
206
251
  - test/omise/test_charge.rb
207
252
  - test/omise/test_customer.rb
253
+ - test/omise/test_dispute.rb
254
+ - test/omise/test_recipient.rb
208
255
  - test/omise/test_refund.rb
209
256
  - test/omise/test_token.rb
210
257
  - test/omise/test_transaction.rb
211
258
  - test/omise/test_transfer.rb
212
259
  - test/support.rb
213
- - test/test_omise.rb
214
260
  has_rdoc:
data/test/test_omise.rb DELETED
@@ -1,7 +0,0 @@
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