omise 0.9.1 → 0.10.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (39) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/publish.yml +34 -0
  3. data/.github/workflows/ruby.yml +11 -11
  4. data/.gitignore +1 -0
  5. data/CHANGELOG.md +23 -1
  6. data/README.md +25 -43
  7. data/lib/omise/account.rb +12 -1
  8. data/lib/omise/all.rb +1 -0
  9. data/lib/omise/charge.rb +8 -0
  10. data/lib/omise/dispute.rb +4 -0
  11. data/lib/omise/link.rb +4 -0
  12. data/lib/omise/receipt.rb +20 -0
  13. data/lib/omise/scheduler.rb +1 -1
  14. data/lib/omise/version.rb +1 -1
  15. data/test/fixtures/api.omise.co/account-get.json +2 -0
  16. data/test/fixtures/api.omise.co/account-patch.json +8 -0
  17. data/test/fixtures/api.omise.co/charges/chrg_test_4yq7duw15p9hdrjp8oq/events-get.json +28 -0
  18. data/test/fixtures/api.omise.co/charges/chrg_test_4yq7duw15p9hdrjp8oq/expire-post.json +51 -0
  19. data/test/fixtures/api.omise.co/disputes/dspt_test_5089off452g5m5te7xs/accept-patch.json +12 -0
  20. data/test/fixtures/api.omise.co/links/link_test_55pcclmznvrv9lc7r9s-delete.json +6 -0
  21. data/test/fixtures/api.omise.co/receipts/rcpt_5ls0b8zb53qmw3mlvfz-get.json +39 -0
  22. data/test/fixtures/api.omise.co/receipts-get.json +90 -0
  23. data/test/omise/test_account.rb +9 -3
  24. data/test/omise/test_attributes.rb +2 -2
  25. data/test/omise/test_balance.rb +2 -2
  26. data/test/omise/test_card.rb +2 -2
  27. data/test/omise/test_chain.rb +4 -4
  28. data/test/omise/test_charge.rb +13 -2
  29. data/test/omise/test_customer.rb +2 -2
  30. data/test/omise/test_dispute.rb +18 -0
  31. data/test/omise/test_document.rb +2 -2
  32. data/test/omise/test_forex.rb +2 -2
  33. data/test/omise/test_link.rb +9 -2
  34. data/test/omise/test_receipt.rb +29 -0
  35. data/test/omise/test_recipient.rb +2 -2
  36. data/test/omise/test_refund.rb +2 -2
  37. data/test/omise/test_scheduler.rb +13 -0
  38. data/test/omise/test_token.rb +2 -2
  39. metadata +21 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3dab8dfce54ab5093f8ad1cbaa63129d3d120ff3d560a06aa40751037da24810
4
- data.tar.gz: 59faec1efb9c9c489f2dabdfca17dc19d98ba115de5bf16c85bdf91979a6c3b0
3
+ metadata.gz: 86f667adb02844ae4a28e2a27d5dc510f525bb6c5b7466e8498fddb09d3f793c
4
+ data.tar.gz: cf02aa9699535883c6ff342fd93dcbb5bd4e39dbcd65d7737b50cf98748cf94a
5
5
  SHA512:
6
- metadata.gz: f3c612f054c9f94c17197c7cf852d0e7581b073886e907ea43f829e994e3da3a4c57a07199869d7264dfb0261fd4902fd99af130654b0b2b4d6c786951cf06d5
7
- data.tar.gz: d77c92c66b6f2c04e5e58d12200005765817c80ff400bb9c04a848db9acce7f3bdba4d59ab67ee1786221d22914a5eeaa2a6b19c75584a5bcb038356a62c30b5
6
+ metadata.gz: 36c8120f9b002f22c684bf6b7926209c31310d7fcb7a0a47b04a9988cf2f6f13a70e5d177fbd133ec923d619da770a812e7cce901dd60ceef36d670abdea1bad
7
+ data.tar.gz: f0d8ff93d321ada34b1a848ebcebc39b313023ed77fbead69af9d0e67b42d4a3dba05e69788160e61593edc4e4f8ccc14e95c4fdefd13ef1db9c2d5aec6bd347
@@ -0,0 +1,34 @@
1
+ name: Publish
2
+
3
+ on:
4
+ push:
5
+ tags:
6
+ - '*'
7
+
8
+ jobs:
9
+ publish:
10
+ runs-on: ubuntu-latest
11
+
12
+ steps:
13
+ - uses: actions/checkout@v3
14
+ - uses: ruby/setup-ruby@v1
15
+ with:
16
+ ruby-version: '3.2'
17
+ bundler-cache: true
18
+
19
+ - name: Build and test with Rake
20
+ run: |
21
+ gem install bundler
22
+ bundle install --jobs 4 --retry 3
23
+ bundle exec rake test
24
+
25
+ - name: Publish to RubyGems
26
+ run: |
27
+ mkdir -p $HOME/.gem
28
+ touch $HOME/.gem/credentials
29
+ chmod 0600 $HOME/.gem/credentials
30
+ printf -- "---\n:rubygems_api_key: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
31
+ gem build *.gemspec
32
+ gem push *.gem
33
+ env:
34
+ GEM_HOST_API_KEY: ${{secrets.GEM_HOST_API_KEY}}
@@ -1,24 +1,24 @@
1
1
  name: Ruby
2
2
 
3
- on: [push]
4
-
3
+ on:
4
+ push:
5
+
5
6
  jobs:
6
7
  build:
7
- runs-on: ubuntu-latest
8
8
  strategy:
9
+ fail-fast: false
9
10
  matrix:
10
- ruby: [ '2.3', '2.4', '2.5', '2.6' ]
11
- name: Ruby ${{ matrix.ruby }}
11
+ os: [ubuntu-latest]
12
+ ruby: [ '2.6', '2.7', '3.0', '3.1', '3.2' ]
13
+ runs-on: ${{ matrix.os }}
12
14
  steps:
13
- - uses: actions/checkout@master
14
- - name: Setup ruby
15
- uses: actions/setup-ruby@v1
15
+ - uses: actions/checkout@v3
16
+ - uses: ruby/setup-ruby@v1
16
17
  with:
17
18
  ruby-version: ${{ matrix.ruby }}
18
- architecture: 'x64'
19
-
19
+ bundler-cache: true
20
20
  - name: Build and test with Rake
21
21
  run: |
22
22
  gem install bundler
23
23
  bundle install --jobs 4 --retry 3
24
- bundle exec rake test
24
+ bundle exec rake test
data/.gitignore CHANGED
@@ -12,3 +12,4 @@
12
12
  *.o
13
13
  *.a
14
14
  mkmf.log
15
+ .DS_Store
data/CHANGELOG.md CHANGED
@@ -2,6 +2,28 @@
2
2
 
3
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
4
 
5
+ ## [0.10.1] 2023-04-20
6
+
7
+ - [Updated] Updated test case for ruby >= 3.0 (https://github.com/omise/omise-ruby/pull/48)
8
+
9
+ ## [0.10.0] 2021-02-16
10
+
11
+ - [Added] Add a new method to fetch all events belonging to a charge (https://github.com/omise/omise-ruby/pull/45)
12
+ - [Added] Add Receipt API (https://github.com/omise/omise-ruby/pull/44)
13
+ - [Added] Allow shortened form of ordinal numbers on Scheduler (https://github.com/omise/omise-ruby/pull/43)
14
+ - [Added] Add update method for Account (https://github.com/omise/omise-ruby/pull/42)
15
+ - [Added] Add accept method for Dispute (https://github.com/omise/omise-ruby/pull/41)
16
+ - [Added] Add expire method for Charge (https://github.com/omise/omise-ruby/pull/40)
17
+ - [Added] Add destroy method for Link (https://github.com/omise/omise-ruby/pull/39)
18
+
19
+ ## [0.9.1] 2019-11-15
20
+
21
+ - [Fixed] Tests
22
+
23
+ ## [0.9.0] 2019-11-15
24
+
25
+ - [Added] Integrations support
26
+
5
27
  ## [0.8.0] 2019-11-04
6
28
 
7
29
  - [Added] Capability object
@@ -73,7 +95,7 @@ An [unreleased] version is not available on rubygems and is subject to changes a
73
95
  ## [0.1.0] 2015-01-19
74
96
 
75
97
  - [Added] Add support for the Refund API.
76
- - [Added] Add a test suite that can be run locally without the need for a
98
+ - [Added] Add a test suite that can be run locally without the need for a
77
99
  network connection or to set Omise keys.
78
100
  - [Added] Add a list method to retrieve a list of objects.
79
101
  - [Changed] Move typecast and load_response methods into a Util module.
data/README.md CHANGED
@@ -3,17 +3,16 @@
3
3
  [![Maintainability](https://api.codeclimate.com/v1/badges/8297834e28572da75cf2/maintainability)](https://codeclimate.com/github/omise/omise-ruby/maintainability)
4
4
  <img alt="GitHub Actions status" src="https://github.com/omise/omise-ruby/workflows/Ruby/badge.svg">
5
5
  [![Gem](https://img.shields.io/gem/v/omise.svg?style=flat)](https://rubygems.org/gems/omise)
6
- [![Join the chat at https://gitter.im/omise/omise-ruby](https://badges.gitter.im/omise/omise-ruby.svg)](https://gitter.im/omise/omise-ruby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
7
6
 
8
7
  ## Installation
9
8
 
10
- Installing via rubygems:
9
+ Add the following to your `Gemfile` and run `bundle install` to install via [RubyGems](https://rubygems.org/gems/omise):
11
10
 
12
11
  ```ruby
13
12
  gem 'omise'
14
13
  ```
15
14
 
16
- Or use the cutting-edge version by installing via github:
15
+ Or use the cutting-edge version by installing via GitHub:
17
16
 
18
17
  ```ruby
19
18
  gem 'omise', github: 'omise/omise-ruby'
@@ -21,28 +20,38 @@ gem 'omise', github: 'omise/omise-ruby'
21
20
 
22
21
  ## Requirements
23
22
 
24
- Requires ruby 1.9.2 or above, the rest-client and json gems.
23
+ Tested on Ruby 2.5 and above
25
24
 
26
25
  ## Configuration
27
26
 
28
27
  First configure your secret key:
29
28
 
30
29
  ```ruby
30
+ require "omise"
31
+
31
32
  Omise.api_key = "skey_test_xxxxxxxxxxxxxxxxxxx"
32
33
  ```
33
34
 
34
- If you need to use the Token API you also need to set your public key:
35
+ After you have implemented [Omise.js](https://www.omise.co/omise-js) on your frontend you can charge the card by passing the token generated by Omise.js into the `card` attribute.
35
36
 
36
37
  ```ruby
37
- Omise.public_api_key = "pkey_test_xxxxxxxxxxxxxxxxxxx"
38
- ```
38
+ # Charge 1000.00 THB
39
+ charge = Omise::Charge.create({
40
+ amount: 1_000_00,
41
+ currency: "thb",
42
+ card: params[:omise_token]
43
+ })
39
44
 
40
- With this set you'll be able to retrieve tokens or create new ones.
45
+ if charge.paid
46
+ # handle success
47
+ puts "thanks"
48
+ else
49
+ # handle failure
50
+ raise charge.failure_code
51
+ end
52
+ ```
41
53
 
42
- However we recommend using [Omise.js](https://www.omise.co/omise-js-api) to
43
- [collect cards](https://www.omise.co/collecting-card-information). When creating a token server side you'll need card data
44
- transiting to and from your server and this requires that your organization be
45
- PCI compliant.
54
+ You can check the complete documentation at [omise.co/docs](https://omise.co/docs).
46
55
 
47
56
  ### API version
48
57
 
@@ -53,18 +62,16 @@ environments with different API versions (e.g. development on the latest but
53
62
  production on the older version).
54
63
 
55
64
  ```ruby
56
- require "omise"
57
- Omise.api_version = "2014-07-27"
65
+ Omise.api_version = "2019-05-29"
58
66
  ```
59
67
 
60
- It is highly recommended to set this version to the current version
61
- you're using.
68
+ It is highly recommended to set this version to the current version you're using.
62
69
 
63
70
  ### Logging
64
71
 
65
- To enable log you can set `Omise.logger` with a Ruby logger. All HTTP requests and responses will be logged.
72
+ To enable logging you can set `Omise.logger` with a Ruby logger. All HTTP requests and responses will be logged.
66
73
 
67
- To disable log, just configure `Omise.logger` to `nil`. Default is disabled.
74
+ To disable logging, just configure `Omise.logger` to `nil`. Default is disabled.
68
75
 
69
76
  An example configuring Rails logger:
70
77
 
@@ -72,31 +79,6 @@ An example configuring Rails logger:
72
79
  Omise.logger = Rails.logger
73
80
  ```
74
81
 
75
- ## Quick Start
76
-
77
- After you have implemented [Omise.js](https://www.omise.co/omise-js-api) on your
78
- frontend you can charge the card by passing the token into the `card` attribute.
79
-
80
- ```ruby
81
- # Charge 1000.00 THB
82
- charge = Omise::Charge.create({
83
- amount: 1_000_00,
84
- currency: "thb",
85
- card: params[:omise_token]
86
- })
87
-
88
- if charge.paid
89
- # handle success
90
- puts "thanks"
91
- else
92
- # handle failure
93
- raise charge.failure_code
94
- end
95
- ```
96
-
97
- You can check the complete documentation at
98
- [omise.co/docs](https://omise.co/docs).
99
-
100
82
  ## Development
101
83
 
102
84
  The test suite can be run with `bundle exec rake test`.
data/lib/omise/account.rb CHANGED
@@ -3,6 +3,17 @@ require "omise/object"
3
3
  module Omise
4
4
  class Account < OmiseObject
5
5
  self.endpoint = "/account"
6
- singleton!
6
+
7
+ def self.retrieve(attributes = {})
8
+ new resource(location, attributes).get(attributes)
9
+ end
10
+
11
+ def reload(attributes = {})
12
+ assign_attributes resource(attributes).get(attributes)
13
+ end
14
+
15
+ def update(attributes = {})
16
+ assign_attributes resource(attributes).patch(attributes)
17
+ end
7
18
  end
8
19
  end
data/lib/omise/all.rb CHANGED
@@ -13,6 +13,7 @@ require "omise/forex"
13
13
  require "omise/integration"
14
14
  require "omise/link"
15
15
  require "omise/occurrence"
16
+ require "omise/receipt"
16
17
  require "omise/recipient"
17
18
  require "omise/refund"
18
19
  require "omise/search"
data/lib/omise/charge.rb CHANGED
@@ -44,6 +44,10 @@ module Omise
44
44
  assign_attributes nested_resource("reverse", options).post
45
45
  end
46
46
 
47
+ def expire(options = {})
48
+ assign_attributes nested_resource("expire", options).post
49
+ end
50
+
47
51
  def customer(options = {})
48
52
  if !defined?(Customer)
49
53
  require "omise/customer"
@@ -68,6 +72,10 @@ module Omise
68
72
  expand_attribute Transaction, "transaction", options
69
73
  end
70
74
 
75
+ def events(attributes = {})
76
+ List.new nested_resource("events", attributes).get(attributes)
77
+ end
78
+
71
79
  def refunds
72
80
  list_attribute RefundList, "refunds"
73
81
  end
data/lib/omise/dispute.rb CHANGED
@@ -28,6 +28,10 @@ module Omise
28
28
  assign_attributes resource(attributes).patch(attributes)
29
29
  end
30
30
 
31
+ def accept(attributes = {})
32
+ assign_attributes nested_resource("accept", attributes).patch(attributes)
33
+ end
34
+
31
35
  def charge(options = {})
32
36
  if !defined?(Charge)
33
37
  require "omise/charge"
data/lib/omise/link.rb CHANGED
@@ -27,6 +27,10 @@ module Omise
27
27
  assign_attributes resource(attributes).get(attributes)
28
28
  end
29
29
 
30
+ def destroy(attributes = {})
31
+ assign_attributes resource(attributes).delete
32
+ end
33
+
30
34
  def charges(options = {})
31
35
  if options.empty?
32
36
  list_attribute ChargeList, "charges"
@@ -0,0 +1,20 @@
1
+ require "omise/object"
2
+ require "omise/list"
3
+
4
+ module Omise
5
+ class Receipt < OmiseObject
6
+ self.endpoint = "/receipts"
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 reload(attributes = {})
17
+ assign_attributes resource(attributes).get(attributes)
18
+ end
19
+ end
20
+ end
@@ -5,7 +5,7 @@ require "omise/schedule"
5
5
  module Omise
6
6
  class Scheduler
7
7
  WEEKDAYS = Date::DAYNAMES.map(&:downcase).freeze
8
- MONTH_WEEKDAYS = %w[first second third fourth last]
8
+ MONTH_WEEKDAYS = %w[first 1st second 2nd third 3rd fourth 4th last]
9
9
  .product(WEEKDAYS)
10
10
  .map { |d| d.join("_") }
11
11
  .freeze
data/lib/omise/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Omise
2
- VERSION = "0.9.1"
2
+ VERSION = "0.10.1"
3
3
  end
@@ -1,6 +1,8 @@
1
1
  {
2
2
  "object": "account",
3
3
  "id": "acct_4yq6tcsyoged5c0ocxd",
4
+ "location": "/account",
4
5
  "email": null,
6
+ "zero_interest_installments": false,
5
7
  "created": "2015-01-15T04:02:14Z"
6
8
  }
@@ -0,0 +1,8 @@
1
+ {
2
+ "object": "account",
3
+ "id": "acct_4yq6tcsyoged5c0ocxd",
4
+ "location": "/account",
5
+ "email": null,
6
+ "zero_interest_installments": true,
7
+ "created": "2015-01-15T04:02:14Z"
8
+ }
@@ -0,0 +1,28 @@
1
+ {
2
+ "object": "list",
3
+ "data": [
4
+ {
5
+ "object": "event",
6
+ "id": "evnt_test_5moztki4ickw5gxwsrh",
7
+ "livemode": false,
8
+ "location": "/events/evnt_test_5moztki4ickw5gxwsrh",
9
+ "key": "charge.update",
10
+ "created_at": "2021-01-29T02:05:20Z"
11
+ },
12
+ {
13
+ "object": "event",
14
+ "id": "evnt_test_5mozta5zc6wdx4genou",
15
+ "livemode": false,
16
+ "location": "/events/evnt_test_5mozta5zc6wdx4genou",
17
+ "key": "charge.create",
18
+ "created_at": "2021-01-29T02:04:31Z"
19
+ }
20
+ ],
21
+ "limit": 20,
22
+ "offset": 0,
23
+ "total": 2,
24
+ "location": "/charges/chrg_test_4yq7duw15p9hdrjp8oq/events",
25
+ "order": "chronological",
26
+ "from": "1970-01-01T00:00:00Z",
27
+ "to": "2021-02-07T10:04:29Z"
28
+ }
@@ -0,0 +1,51 @@
1
+ {
2
+ "object": "charge",
3
+ "id": "chrg_test_4yq7duw15p9hdrjp8oq",
4
+ "livemode": false,
5
+ "location": "/charges/chrg_test_4yq7duw15p9hdrjp8oq",
6
+ "amount": 100000,
7
+ "currency": "thb",
8
+ "description": "Charge for order 3947",
9
+ "capture": true,
10
+ "authorized": false,
11
+ "reversed": false,
12
+ "captured": false,
13
+ "expired": true,
14
+ "transaction": "trxn_test_4yq7duwb9jts1vxgqua",
15
+ "refunded": 0,
16
+ "refunds": {
17
+ "object": "list",
18
+ "from": "1970-01-01T00:00:00+00:00",
19
+ "to": "2015-01-16T07:23:49+00:00",
20
+ "offset": 0,
21
+ "limit": 20,
22
+ "total": 1,
23
+ "data": [
24
+
25
+ ],
26
+ "location": "/charges/chrg_test_4yq7duw15p9hdrjp8oq/refunds"
27
+ },
28
+ "failure_code": null,
29
+ "failure_message": null,
30
+ "card": {
31
+ "object": "card",
32
+ "id": "card_test_4yq6tuucl9h4erukfl0",
33
+ "livemode": false,
34
+ "location": "/customers/cust_test_4yq6txdpfadhbaqnwp3/cards/card_test_4yq6tuucl9h4erukfl0",
35
+ "country": "",
36
+ "city": "Bangkok",
37
+ "postal_code": "10320",
38
+ "financing": "",
39
+ "last_digits": "4242",
40
+ "brand": "Visa",
41
+ "expiration_month": 1,
42
+ "expiration_year": 2017,
43
+ "fingerprint": "sRF/oMw2UQJJp/WbU+2/ZbVzwROjpMf1lyhOHhOqziw=",
44
+ "name": "JOHN DOE",
45
+ "security_code_check": true,
46
+ "created": "2015-01-15T04:03:40Z"
47
+ },
48
+ "customer": "cust_test_4yq6txdpfadhbaqnwp3",
49
+ "ip": null,
50
+ "created": "2015-01-15T05:00:29Z"
51
+ }
@@ -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": "lost",
9
+ "message": null,
10
+ "charge": "chrg_test_5089odjlzg9j7tw4i1q",
11
+ "created": "2015-06-02T10:22:32Z"
12
+ }
@@ -0,0 +1,6 @@
1
+ {
2
+ "object": "link",
3
+ "id": "link_test_55pcclmznvrv9lc7r9s",
4
+ "livemode": false,
5
+ "deleted": true
6
+ }
@@ -0,0 +1,39 @@
1
+ {
2
+ "object": "receipt",
3
+ "id": "rcpt_5ls0b8zb53qmw3mlvfz",
4
+ "livemode": true,
5
+ "location": "/receipts/rcpt_5ls0b8zb53qmw3mlvfz",
6
+ "credit_note": false,
7
+ "charge_fee": 7,
8
+ "subtotal": 7,
9
+ "transfer_fee": 0,
10
+ "voided_fee": 0,
11
+ "vat": 0,
12
+ "wht": 0,
13
+ "total": 7,
14
+ "company_address": "123 The Road, Thailand",
15
+ "company_name": "Omise",
16
+ "company_tax_id": "0123456789012",
17
+ "currency": "THB",
18
+ "customer_address": "456 The Street, Singapore",
19
+ "customer_email": "john.doe@omise.co",
20
+ "customer_name": "John Doe",
21
+ "customer_statement_name": "John Doe",
22
+ "customer_tax_id": "10000",
23
+ "number": "OMTH202011050019",
24
+ "created_at": "2020-11-05T18:02:05Z",
25
+ "issued_on": "2020-11-05",
26
+ "adjustment_transaction": {
27
+ "object": "transaction",
28
+ "id": "trxn_5ls0b8zftdzm5vw90d6",
29
+ "livemode": true,
30
+ "currency": "THB",
31
+ "amount": 0,
32
+ "location": "/transactions/trxn_5ls0b8zftdzm5vw90d6",
33
+ "direction": "credit",
34
+ "key": "receipt.vat_adjustment.credit",
35
+ "origin": "rcpt_5ls0b8zb53qmw3mlvfz",
36
+ "transferable_at": "2020-11-05T18:02:05Z",
37
+ "created_at": "2020-11-05T18:02:05Z"
38
+ }
39
+ }
@@ -0,0 +1,90 @@
1
+ {
2
+ "object": "receipt_list",
3
+ "data": [
4
+ {
5
+ "object": "receipt",
6
+ "id": "rcpt_5lrm8qjcaj5vpu2790m",
7
+ "livemode": true,
8
+ "location": "/receipts/rcpt_5lrm8qjcaj5vpu2790m",
9
+ "credit_note": false,
10
+ "charge_fee": 7,
11
+ "subtotal": 7,
12
+ "transfer_fee": 0,
13
+ "voided_fee": 0,
14
+ "vat": 0,
15
+ "wht": 0,
16
+ "total": 7,
17
+ "company_address": "123 The Road, Thailand",
18
+ "company_name": "Omise",
19
+ "company_tax_id": "0123456789012",
20
+ "currency": "THB",
21
+ "customer_address": "456 The Street, Singapore",
22
+ "customer_email": "john.doe@omise.co",
23
+ "customer_name": "John Doe",
24
+ "customer_statement_name": "John Doe",
25
+ "customer_tax_id": "10000",
26
+ "number": "OMTH202011050018",
27
+ "created_at": "2020-11-05T18:02:05Z",
28
+ "issued_on": "2020-11-05",
29
+ "adjustment_transaction": {
30
+ "object": "transaction",
31
+ "id": "trxn_5lrm8qjiaye00x5dv4r",
32
+ "livemode": true,
33
+ "currency": "THB",
34
+ "amount": 0,
35
+ "location": "/transactions/trxn_5lrm8qjiaye00x5dv4r",
36
+ "direction": "credit",
37
+ "key": "receipt.vat_adjustment.credit",
38
+ "origin": "rcpt_5lrm8qjcaj5vpu2790m",
39
+ "transferable_at": "2020-11-05T18:02:05Z",
40
+ "created_at": "2020-11-05T18:02:05Z"
41
+ }
42
+ },
43
+ {
44
+ "object": "receipt",
45
+ "id": "rcpt_5ls0b8zb53qmw3mlvfz",
46
+ "livemode": true,
47
+ "location": "/receipts/rcpt_5ls0b8zb53qmw3mlvfz",
48
+ "credit_note": false,
49
+ "charge_fee": 7,
50
+ "subtotal": 7,
51
+ "transfer_fee": 0,
52
+ "voided_fee": 0,
53
+ "vat": 0,
54
+ "wht": 0,
55
+ "total": 7,
56
+ "company_address": "123 The Road, Thailand",
57
+ "company_name": "Omise",
58
+ "company_tax_id": "0123456789012",
59
+ "currency": "THB",
60
+ "customer_address": "456 The Street, Singapore",
61
+ "customer_email": "john.doe@omise.co",
62
+ "customer_name": "John Doe",
63
+ "customer_statement_name": "John Doe",
64
+ "customer_tax_id": "10000",
65
+ "number": "OMTH202011050019",
66
+ "created_at": "2020-11-05T18:02:05Z",
67
+ "issued_on": "2020-11-05",
68
+ "adjustment_transaction": {
69
+ "object": "transaction",
70
+ "id": "trxn_5ls0b8zftdzm5vw90d6",
71
+ "livemode": true,
72
+ "currency": "THB",
73
+ "amount": 0,
74
+ "location": "/transactions/trxn_5ls0b8zftdzm5vw90d6",
75
+ "direction": "credit",
76
+ "key": "receipt.vat_adjustment.credit",
77
+ "origin": "rcpt_5ls0b8zb53qmw3mlvfz",
78
+ "transferable_at": "2020-11-05T18:02:05Z",
79
+ "created_at": "2020-11-05T18:02:05Z"
80
+ }
81
+ }
82
+ ],
83
+ "limit": 20,
84
+ "offset": 0,
85
+ "total": 2,
86
+ "location": "/receipts",
87
+ "order": "chronological",
88
+ "from": "1970-01-01T00:00:00Z",
89
+ "to": "2021-02-07T23:59:59Z"
90
+ }
@@ -10,10 +10,16 @@ class TestAccount < Omise::Test
10
10
  assert_equal "/account", @account.location
11
11
  end
12
12
 
13
- def test_that_we_can_reload_a_customer
14
- @account.attributes.taint
13
+ def test_that_we_can_reload_the_account
14
+ @account.attributes.freeze
15
15
  @account.reload
16
16
 
17
- refute @account.attributes.tainted?
17
+ refute @account.attributes.frozen?
18
+ end
19
+
20
+ def test_that_we_can_update_the_account
21
+ @account.update(zero_interest_installments: true)
22
+
23
+ assert @account.zero_interest_installments
18
24
  end
19
25
  end
@@ -40,10 +40,10 @@ class TestAttributes < Omise::Test
40
40
  end
41
41
 
42
42
  def test_that_we_can_update_the_teapot_attributes
43
- @teapot.attributes.taint
43
+ @teapot.attributes.freeze
44
44
  @teapot.assign_attributes({})
45
45
 
46
- refute @teapot.attributes.tainted?
46
+ refute @teapot.attributes.frozen?
47
47
  end
48
48
 
49
49
  def test_that_we_can_tell_if_a_teapot_has_not_been_destroyed
@@ -11,9 +11,9 @@ class TestBalance < Omise::Test
11
11
  end
12
12
 
13
13
  def test_that_we_can_reload_a_customer
14
- @balance.attributes.taint
14
+ @balance.attributes.freeze
15
15
  @balance.reload
16
16
 
17
- refute @balance.attributes.tainted?
17
+ refute @balance.attributes.frozen?
18
18
  end
19
19
  end
@@ -25,10 +25,10 @@ class TestCard < Omise::Test
25
25
  end
26
26
 
27
27
  def test_that_a_card_can_be_reloaded
28
- @card.attributes.taint
28
+ @card.attributes.freeze
29
29
  @card.reload
30
30
 
31
- refute @card.attributes.tainted?
31
+ refute @card.attributes.frozen?
32
32
  end
33
33
 
34
34
  def test_that_retrieveing_a_non_existing_card_will_raise_an_error
@@ -21,20 +21,20 @@ class TestChain < Omise::Test
21
21
  end
22
22
 
23
23
  def test_that_we_can_reload_a_chain
24
- @chain.attributes.taint
24
+ @chain.attributes.freeze
25
25
  @chain.reload
26
26
 
27
- refute @chain.attributes.tainted?
27
+ refute @chain.attributes.frozen?
28
28
  end
29
29
 
30
30
  def test_that_we_can_revoke_a_chain
31
- @chain.attributes.taint
31
+ @chain.attributes.freeze
32
32
 
33
33
  refute @chain.revoked
34
34
 
35
35
  @chain.revoke
36
36
 
37
37
  assert @chain.revoked?
38
- refute @chain.attributes.tainted?
38
+ refute @chain.attributes.frozen?
39
39
  end
40
40
  end
@@ -57,10 +57,10 @@ class TestCharge < Omise::Test
57
57
  end
58
58
 
59
59
  def test_that_we_can_reload_a_charge
60
- @charge.attributes.taint
60
+ @charge.attributes.freeze
61
61
  @charge.reload
62
62
 
63
- refute @charge.attributes.tainted?
63
+ refute @charge.attributes.frozen?
64
64
  end
65
65
 
66
66
  def test_that_retrieveing_a_non_existing_charge_will_raise_an_error
@@ -111,6 +111,10 @@ class TestCharge < Omise::Test
111
111
  assert @charge.reverse
112
112
  end
113
113
 
114
+ def test_that_we_can_set_a_charge_to_expire
115
+ assert @charge.expire
116
+ end
117
+
114
118
  def test_that_search_returns_a_scoped_search
115
119
  assert_instance_of Omise::SearchScope, Omise::Charge.search
116
120
  assert_equal "charge", Omise::Charge.search.scope
@@ -120,4 +124,11 @@ class TestCharge < Omise::Test
120
124
  assert_instance_of Omise::Scheduler, Omise::Charge.schedule
121
125
  assert_equal "charge", Omise::Charge.schedule.type
122
126
  end
127
+
128
+ def test_that_we_can_fetch_an_event_list_for_a_given_charge
129
+ events = @charge.events
130
+
131
+ assert events
132
+ assert_instance_of Omise::List, events
133
+ end
123
134
  end
@@ -37,10 +37,10 @@ class TestCustomer < Omise::Test
37
37
  end
38
38
 
39
39
  def test_that_we_can_reload_a_customer
40
- @customer.attributes.taint
40
+ @customer.attributes.freeze
41
41
  @customer.reload
42
42
 
43
- refute @customer.attributes.tainted?
43
+ refute @customer.attributes.frozen?
44
44
  end
45
45
 
46
46
  def test_that_we_can_charge_a_customer
@@ -34,12 +34,30 @@ class TestDispute < Omise::Test
34
34
  assert_equal "dspt_test_5089off452g5m5te7xs", @dispute.id
35
35
  end
36
36
 
37
+ def test_that_we_can_reload_a_dispute
38
+ @dispute.attributes.freeze
39
+ @dispute.reload
40
+
41
+ refute @dispute.attributes.frozen?
42
+ end
43
+
37
44
  def test_that_we_can_update_a_dispute
38
45
  @dispute.update(message: "Your dispute message")
39
46
 
40
47
  assert_equal @dispute.message, "Your dispute message"
41
48
  end
42
49
 
50
+ def test_that_we_can_accept_a_dispute
51
+ @dispute.attributes.freeze
52
+
53
+ assert_equal @dispute.status, "open"
54
+
55
+ @dispute.accept
56
+
57
+ assert_equal @dispute.status, "lost"
58
+ refute @dispute.attributes.frozen?
59
+ end
60
+
43
61
  def test_that_we_can_retrieve_a_list_of_documents
44
62
  assert_instance_of Omise::DocumentList, @dispute.documents
45
63
  end
@@ -19,10 +19,10 @@ class TestDocument < Omise::Test
19
19
  end
20
20
 
21
21
  def test_that_a_document_can_be_reloaded
22
- @document.attributes.taint
22
+ @document.attributes.freeze
23
23
  @document.reload
24
24
 
25
- refute @document.attributes.tainted?
25
+ refute @document.attributes.frozen?
26
26
  end
27
27
 
28
28
  def test_that_we_can_destroy_a_document
@@ -18,9 +18,9 @@ class TestForex < Omise::Test
18
18
  end
19
19
 
20
20
  def test_that_we_can_reload_a_forex
21
- @forex.attributes.taint
21
+ @forex.attributes.freeze
22
22
  @forex.reload
23
23
 
24
- refute @forex.attributes.tainted?
24
+ refute @forex.attributes.frozen?
25
25
  end
26
26
  end
@@ -17,6 +17,13 @@ class TestLink < Omise::Test
17
17
  assert_equal "link_test_55pcclmznvrv9lc7r9s", @link.id
18
18
  end
19
19
 
20
+ def test_that_we_can_destroy_a_link
21
+ @link.destroy
22
+
23
+ assert @link.deleted
24
+ assert @link.destroyed?
25
+ end
26
+
20
27
  def test_that_we_can_list_all_links
21
28
  links = Omise::Link.list
22
29
 
@@ -24,10 +31,10 @@ class TestLink < Omise::Test
24
31
  end
25
32
 
26
33
  def test_that_we_can_reload_a_link
27
- @link.attributes.taint
34
+ @link.attributes.freeze
28
35
  @link.reload
29
36
 
30
- refute @link.attributes.tainted?
37
+ refute @link.attributes.frozen?
31
38
  end
32
39
 
33
40
  def test_that_a_link_has_a_list_of_charges
@@ -0,0 +1,29 @@
1
+ require "support"
2
+
3
+ class TestReceipt < Omise::Test
4
+ setup do
5
+ @receipt = Omise::Receipt.retrieve("rcpt_5ls0b8zb53qmw3mlvfz")
6
+ end
7
+
8
+ def test_that_we_can_list_all_receipts
9
+ receipts = Omise::Receipt.list
10
+
11
+ assert receipts
12
+ assert_instance_of Omise::List, receipts
13
+ assert_instance_of Omise::Receipt, receipts.first
14
+ end
15
+
16
+ def test_that_we_can_retrieve_a_receipt
17
+ receipt = Omise::Receipt.retrieve("rcpt_5ls0b8zb53qmw3mlvfz")
18
+
19
+ assert receipt
20
+ assert_instance_of Omise::Receipt, receipt
21
+ end
22
+
23
+ def test_that_we_can_reload_a_receipt
24
+ @receipt.attributes.freeze
25
+ @receipt.reload
26
+
27
+ refute @receipt.attributes.frozen?
28
+ end
29
+ end
@@ -23,10 +23,10 @@ class TestRecipient < Omise::Test
23
23
  end
24
24
 
25
25
  def test_that_we_can_reload_a_recipient
26
- @recipient.attributes.taint
26
+ @recipient.attributes.freeze
27
27
  @recipient.reload
28
28
 
29
- refute @recipient.attributes.tainted?
29
+ refute @recipient.attributes.frozen?
30
30
  end
31
31
 
32
32
  def test_that_we_can_destroy_a_recipient
@@ -27,10 +27,10 @@ class TestRefund < Omise::Test
27
27
  end
28
28
 
29
29
  def test_that_a_refund_can_be_reloaded
30
- @refund.attributes.taint
30
+ @refund.attributes.freeze
31
31
  @refund.reload
32
32
 
33
- refute @refund.attributes.tainted?
33
+ refute @refund.attributes.frozen?
34
34
  end
35
35
 
36
36
  def test_that_retrieveing_a_non_existing_refund_will_raise_an_error
@@ -87,6 +87,16 @@ class TestScheduler < Omise::Test
87
87
  assert_equal "first_monday", scheduler.to_attributes[:on][:weekday_of_month]
88
88
  end
89
89
 
90
+ def test_we_can_set_month_with_weekday_in_other_formats
91
+ scheduler = @scheduler.every(1).month(on: "1st_monday")
92
+
93
+ assert_scheduler_attributes(@scheduler)
94
+ refute_equal scheduler.object_id, @scheduler.object_id
95
+ assert_equal 1, scheduler.to_attributes[:every]
96
+ assert_equal "month", scheduler.to_attributes[:period]
97
+ assert_equal "1st_monday", scheduler.to_attributes[:on][:weekday_of_month]
98
+ end
99
+
90
100
  def test_we_can_set_months_with_weekday
91
101
  scheduler = @scheduler.every(3).months(on: "last_friday")
92
102
 
@@ -155,6 +165,9 @@ class TestScheduler < Omise::Test
155
165
  scheduler = @scheduler.parse("every month on the third Thursday until January 1st 2020")
156
166
  assert_scheduler_attributes(scheduler, 1, "month", "2020-01-01", weekday_of_month: "third_thursday")
157
167
 
168
+ scheduler = @scheduler.parse("every month on the 2nd Monday until January 1st 2020")
169
+ assert_scheduler_attributes(scheduler, 1, "month", "2020-01-01", weekday_of_month: "2nd_monday")
170
+
158
171
  scheduler = @scheduler.parse("every 3 months on 1, 2 and 3 until January 1st 2020")
159
172
  assert_scheduler_attributes(scheduler, 3, "month", "2020-01-01", days_of_month: [1, 2, 3])
160
173
  end
@@ -23,9 +23,9 @@ class TestToken < Omise::Test
23
23
  end
24
24
 
25
25
  def test_that_we_can_reload_a_token
26
- @token.attributes.taint
26
+ @token.attributes.freeze
27
27
  @token.reload
28
28
 
29
- refute @token.attributes.tainted?
29
+ refute @token.attributes.frozen?
30
30
  end
31
31
  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.9.1
4
+ version: 0.10.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robin Clart
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-11-19 00:00:00.000000000 Z
11
+ date: 2023-04-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rest-client
@@ -101,6 +101,7 @@ executables: []
101
101
  extensions: []
102
102
  extra_rdoc_files: []
103
103
  files:
104
+ - ".github/workflows/publish.yml"
104
105
  - ".github/workflows/ruby.yml"
105
106
  - ".gitignore"
106
107
  - CHANGELOG.md
@@ -137,6 +138,7 @@ files:
137
138
  - lib/omise/object.rb
138
139
  - lib/omise/occurrence.rb
139
140
  - lib/omise/occurrence_list.rb
141
+ - lib/omise/receipt.rb
140
142
  - lib/omise/recipient.rb
141
143
  - lib/omise/refund.rb
142
144
  - lib/omise/refund_list.rb
@@ -156,6 +158,7 @@ files:
156
158
  - lib/omise/version.rb
157
159
  - omise.gemspec
158
160
  - test/fixtures/api.omise.co/account-get.json
161
+ - test/fixtures/api.omise.co/account-patch.json
159
162
  - test/fixtures/api.omise.co/balance-get.json
160
163
  - test/fixtures/api.omise.co/capability-get.json
161
164
  - test/fixtures/api.omise.co/chains-get.json
@@ -170,6 +173,8 @@ files:
170
173
  - test/fixtures/api.omise.co/charges/chrg_test_4yq7duw15p9hdrjp8oq-get.json
171
174
  - test/fixtures/api.omise.co/charges/chrg_test_4yq7duw15p9hdrjp8oq-patch.json
172
175
  - test/fixtures/api.omise.co/charges/chrg_test_4yq7duw15p9hdrjp8oq/capture-post.json
176
+ - test/fixtures/api.omise.co/charges/chrg_test_4yq7duw15p9hdrjp8oq/events-get.json
177
+ - test/fixtures/api.omise.co/charges/chrg_test_4yq7duw15p9hdrjp8oq/expire-post.json
173
178
  - test/fixtures/api.omise.co/charges/chrg_test_4yq7duw15p9hdrjp8oq/refunds-get.json
174
179
  - test/fixtures/api.omise.co/charges/chrg_test_4yq7duw15p9hdrjp8oq/refunds-post.json
175
180
  - test/fixtures/api.omise.co/charges/chrg_test_4yq7duw15p9hdrjp8oq/refunds/404-get.json
@@ -191,6 +196,7 @@ files:
191
196
  - test/fixtures/api.omise.co/disputes/closed-get.json
192
197
  - test/fixtures/api.omise.co/disputes/dspt_test_5089off452g5m5te7xs-get.json
193
198
  - test/fixtures/api.omise.co/disputes/dspt_test_5089off452g5m5te7xs-patch.json
199
+ - test/fixtures/api.omise.co/disputes/dspt_test_5089off452g5m5te7xs/accept-patch.json
194
200
  - test/fixtures/api.omise.co/disputes/dspt_test_5089off452g5m5te7xs/documents-get.json
195
201
  - test/fixtures/api.omise.co/disputes/dspt_test_5089off452g5m5te7xs/documents-post.json
196
202
  - test/fixtures/api.omise.co/disputes/dspt_test_5089off452g5m5te7xs/documents/docu_test_55869onwfm2g3bsw8d8-delete.json
@@ -203,8 +209,11 @@ files:
203
209
  - test/fixtures/api.omise.co/integrations/integration_test_5h24qlv37qyx537p1ub-get.json
204
210
  - test/fixtures/api.omise.co/links-get.json
205
211
  - test/fixtures/api.omise.co/links-post.json
212
+ - test/fixtures/api.omise.co/links/link_test_55pcclmznvrv9lc7r9s-delete.json
206
213
  - test/fixtures/api.omise.co/links/link_test_55pcclmznvrv9lc7r9s-get.json
207
214
  - test/fixtures/api.omise.co/occurrences/occu_test_57s33hmja9t3fs4wmop-get.json
215
+ - test/fixtures/api.omise.co/receipts-get.json
216
+ - test/fixtures/api.omise.co/receipts/rcpt_5ls0b8zb53qmw3mlvfz-get.json
208
217
  - test/fixtures/api.omise.co/recipients-get.json
209
218
  - test/fixtures/api.omise.co/recipients-post.json
210
219
  - test/fixtures/api.omise.co/recipients/recp_test_50894vc13y8z4v51iuc-delete.json
@@ -247,6 +256,7 @@ files:
247
256
  - test/omise/test_link.rb
248
257
  - test/omise/test_list.rb
249
258
  - test/omise/test_occurrence.rb
259
+ - test/omise/test_receipt.rb
250
260
  - test/omise/test_recipient.rb
251
261
  - test/omise/test_refund.rb
252
262
  - test/omise/test_resource.rb
@@ -279,12 +289,13 @@ required_rubygems_version: !ruby/object:Gem::Requirement
279
289
  - !ruby/object:Gem::Version
280
290
  version: '0'
281
291
  requirements: []
282
- rubygems_version: 3.0.3
292
+ rubygems_version: 3.4.10
283
293
  signing_key:
284
294
  specification_version: 4
285
295
  summary: Omise Ruby client
286
296
  test_files:
287
297
  - test/fixtures/api.omise.co/account-get.json
298
+ - test/fixtures/api.omise.co/account-patch.json
288
299
  - test/fixtures/api.omise.co/balance-get.json
289
300
  - test/fixtures/api.omise.co/capability-get.json
290
301
  - test/fixtures/api.omise.co/chains-get.json
@@ -299,6 +310,8 @@ test_files:
299
310
  - test/fixtures/api.omise.co/charges/chrg_test_4yq7duw15p9hdrjp8oq-get.json
300
311
  - test/fixtures/api.omise.co/charges/chrg_test_4yq7duw15p9hdrjp8oq-patch.json
301
312
  - test/fixtures/api.omise.co/charges/chrg_test_4yq7duw15p9hdrjp8oq/capture-post.json
313
+ - test/fixtures/api.omise.co/charges/chrg_test_4yq7duw15p9hdrjp8oq/events-get.json
314
+ - test/fixtures/api.omise.co/charges/chrg_test_4yq7duw15p9hdrjp8oq/expire-post.json
302
315
  - test/fixtures/api.omise.co/charges/chrg_test_4yq7duw15p9hdrjp8oq/refunds-get.json
303
316
  - test/fixtures/api.omise.co/charges/chrg_test_4yq7duw15p9hdrjp8oq/refunds-post.json
304
317
  - test/fixtures/api.omise.co/charges/chrg_test_4yq7duw15p9hdrjp8oq/refunds/404-get.json
@@ -320,6 +333,7 @@ test_files:
320
333
  - test/fixtures/api.omise.co/disputes/closed-get.json
321
334
  - test/fixtures/api.omise.co/disputes/dspt_test_5089off452g5m5te7xs-get.json
322
335
  - test/fixtures/api.omise.co/disputes/dspt_test_5089off452g5m5te7xs-patch.json
336
+ - test/fixtures/api.omise.co/disputes/dspt_test_5089off452g5m5te7xs/accept-patch.json
323
337
  - test/fixtures/api.omise.co/disputes/dspt_test_5089off452g5m5te7xs/documents-get.json
324
338
  - test/fixtures/api.omise.co/disputes/dspt_test_5089off452g5m5te7xs/documents-post.json
325
339
  - test/fixtures/api.omise.co/disputes/dspt_test_5089off452g5m5te7xs/documents/docu_test_55869onwfm2g3bsw8d8-delete.json
@@ -332,8 +346,11 @@ test_files:
332
346
  - test/fixtures/api.omise.co/integrations/integration_test_5h24qlv37qyx537p1ub-get.json
333
347
  - test/fixtures/api.omise.co/links-get.json
334
348
  - test/fixtures/api.omise.co/links-post.json
349
+ - test/fixtures/api.omise.co/links/link_test_55pcclmznvrv9lc7r9s-delete.json
335
350
  - test/fixtures/api.omise.co/links/link_test_55pcclmznvrv9lc7r9s-get.json
336
351
  - test/fixtures/api.omise.co/occurrences/occu_test_57s33hmja9t3fs4wmop-get.json
352
+ - test/fixtures/api.omise.co/receipts-get.json
353
+ - test/fixtures/api.omise.co/receipts/rcpt_5ls0b8zb53qmw3mlvfz-get.json
337
354
  - test/fixtures/api.omise.co/recipients-get.json
338
355
  - test/fixtures/api.omise.co/recipients-post.json
339
356
  - test/fixtures/api.omise.co/recipients/recp_test_50894vc13y8z4v51iuc-delete.json
@@ -376,6 +393,7 @@ test_files:
376
393
  - test/omise/test_link.rb
377
394
  - test/omise/test_list.rb
378
395
  - test/omise/test_occurrence.rb
396
+ - test/omise/test_receipt.rb
379
397
  - test/omise/test_recipient.rb
380
398
  - test/omise/test_refund.rb
381
399
  - test/omise/test_resource.rb