-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
179 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
require "omise/object" | ||
require "omise/list" | ||
|
||
module Omise | ||
class Receipt < OmiseObject | ||
self.endpoint = "/receipts" | ||
|
||
def self.retrieve(id, attributes = {}) | ||
new resource(location(id), attributes).get(attributes) | ||
end | ||
|
||
def self.list(attributes = {}) | ||
List.new resource(location, attributes).get(attributes) | ||
end | ||
|
||
def reload(attributes = {}) | ||
assign_attributes resource(attributes).get(attributes) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
{ | ||
"object": "receipt_list", | ||
"data": [ | ||
{ | ||
"object": "receipt", | ||
"id": "rcpt_5lrm8qjcaj5vpu2790m", | ||
"livemode": true, | ||
"location": "/receipts/rcpt_5lrm8qjcaj5vpu2790m", | ||
"credit_note": false, | ||
"charge_fee": 7, | ||
"subtotal": 7, | ||
"transfer_fee": 0, | ||
"voided_fee": 0, | ||
"vat": 0, | ||
"wht": 0, | ||
"total": 7, | ||
"company_address": "123 The Road, Thailand", | ||
"company_name": "Omise", | ||
"company_tax_id": "0123456789012", | ||
"currency": "THB", | ||
"customer_address": "456 The Street, Singapore", | ||
"customer_email": "john.doe@omise.co", | ||
"customer_name": "John Doe", | ||
"customer_statement_name": "John Doe", | ||
"customer_tax_id": "10000", | ||
"number": "OMTH202011050018", | ||
"created_at": "2020-11-05T18:02:05Z", | ||
"issued_on": "2020-11-05", | ||
"adjustment_transaction": { | ||
"object": "transaction", | ||
"id": "trxn_5lrm8qjiaye00x5dv4r", | ||
"livemode": true, | ||
"currency": "THB", | ||
"amount": 0, | ||
"location": "/transactions/trxn_5lrm8qjiaye00x5dv4r", | ||
"direction": "credit", | ||
"key": "receipt.vat_adjustment.credit", | ||
"origin": "rcpt_5lrm8qjcaj5vpu2790m", | ||
"transferable_at": "2020-11-05T18:02:05Z", | ||
"created_at": "2020-11-05T18:02:05Z" | ||
} | ||
}, | ||
{ | ||
"object": "receipt", | ||
"id": "rcpt_5ls0b8zb53qmw3mlvfz", | ||
"livemode": true, | ||
"location": "/receipts/rcpt_5ls0b8zb53qmw3mlvfz", | ||
"credit_note": false, | ||
"charge_fee": 7, | ||
"subtotal": 7, | ||
"transfer_fee": 0, | ||
"voided_fee": 0, | ||
"vat": 0, | ||
"wht": 0, | ||
"total": 7, | ||
"company_address": "123 The Road, Thailand", | ||
"company_name": "Omise", | ||
"company_tax_id": "0123456789012", | ||
"currency": "THB", | ||
"customer_address": "456 The Street, Singapore", | ||
"customer_email": "john.doe@omise.co", | ||
"customer_name": "John Doe", | ||
"customer_statement_name": "John Doe", | ||
"customer_tax_id": "10000", | ||
"number": "OMTH202011050019", | ||
"created_at": "2020-11-05T18:02:05Z", | ||
"issued_on": "2020-11-05", | ||
"adjustment_transaction": { | ||
"object": "transaction", | ||
"id": "trxn_5ls0b8zftdzm5vw90d6", | ||
"livemode": true, | ||
"currency": "THB", | ||
"amount": 0, | ||
"location": "/transactions/trxn_5ls0b8zftdzm5vw90d6", | ||
"direction": "credit", | ||
"key": "receipt.vat_adjustment.credit", | ||
"origin": "rcpt_5ls0b8zb53qmw3mlvfz", | ||
"transferable_at": "2020-11-05T18:02:05Z", | ||
"created_at": "2020-11-05T18:02:05Z" | ||
} | ||
} | ||
], | ||
"limit": 20, | ||
"offset": 0, | ||
"total": 2, | ||
"location": "/receipts", | ||
"order": "chronological", | ||
"from": "1970-01-01T00:00:00Z", | ||
"to": "2021-02-07T23:59:59Z" | ||
} |
39 changes: 39 additions & 0 deletions
39
test/fixtures/api.omise.co/receipts/rcpt_5ls0b8zb53qmw3mlvfz-get.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
{ | ||
"object": "receipt", | ||
"id": "rcpt_5ls0b8zb53qmw3mlvfz", | ||
"livemode": true, | ||
"location": "/receipts/rcpt_5ls0b8zb53qmw3mlvfz", | ||
"credit_note": false, | ||
"charge_fee": 7, | ||
"subtotal": 7, | ||
"transfer_fee": 0, | ||
"voided_fee": 0, | ||
"vat": 0, | ||
"wht": 0, | ||
"total": 7, | ||
"company_address": "123 The Road, Thailand", | ||
"company_name": "Omise", | ||
"company_tax_id": "0123456789012", | ||
"currency": "THB", | ||
"customer_address": "456 The Street, Singapore", | ||
"customer_email": "john.doe@omise.co", | ||
"customer_name": "John Doe", | ||
"customer_statement_name": "John Doe", | ||
"customer_tax_id": "10000", | ||
"number": "OMTH202011050019", | ||
"created_at": "2020-11-05T18:02:05Z", | ||
"issued_on": "2020-11-05", | ||
"adjustment_transaction": { | ||
"object": "transaction", | ||
"id": "trxn_5ls0b8zftdzm5vw90d6", | ||
"livemode": true, | ||
"currency": "THB", | ||
"amount": 0, | ||
"location": "/transactions/trxn_5ls0b8zftdzm5vw90d6", | ||
"direction": "credit", | ||
"key": "receipt.vat_adjustment.credit", | ||
"origin": "rcpt_5ls0b8zb53qmw3mlvfz", | ||
"transferable_at": "2020-11-05T18:02:05Z", | ||
"created_at": "2020-11-05T18:02:05Z" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
require "support" | ||
|
||
class TestReceipt < Omise::Test | ||
setup do | ||
@receipt = Omise::Receipt.retrieve("rcpt_5ls0b8zb53qmw3mlvfz") | ||
end | ||
|
||
def test_that_we_can_list_all_receipts | ||
receipts = Omise::Receipt.list | ||
|
||
assert receipts | ||
assert_instance_of Omise::List, receipts | ||
assert_instance_of Omise::Receipt, receipts.first | ||
end | ||
|
||
def test_that_we_can_retrieve_a_receipt | ||
receipt = Omise::Receipt.retrieve("rcpt_5ls0b8zb53qmw3mlvfz") | ||
|
||
assert receipt | ||
assert_instance_of Omise::Receipt, receipt | ||
end | ||
|
||
def test_that_we_can_reload_a_receipt | ||
@receipt.attributes.taint | ||
@receipt.reload | ||
|
||
refute @receipt.attributes.tainted? | ||
end | ||
end |