Browse Source

Merge pull request #475 from Shopify/tender-transactions-endpoint

Add new tender transaction resource
Kris Penney 6 years ago
parent
commit
b4b9b657be

+ 6 - 0
lib/shopify_api/resources/tender_transaction.rb

@@ -0,0 +1,6 @@
+# frozen_string_literal: true
+
+module ShopifyAPI
+  class TenderTransaction < Base
+  end
+end

+ 52 - 0
test/fixtures/tender_transactions.json

@@ -0,0 +1,52 @@
+{
+  "tender_transactions": [
+    {
+      "id": 1,
+      "order_id": 450789469,
+      "amount": "138.46",
+      "currency": "CAD",
+      "user_id": null,
+      "test": true,
+      "processed_at": "2018-08-09T15:43:39-04:00",
+      "updated_at": "2018-08-09T15:43:41-04:00",
+      "remote_reference": "1118366",
+      "payment_method": "credit_card",
+      "payment_details": {
+        "credit_card_number": "•••• •••• •••• 1",
+        "credit_card_company": "Bogus"
+      }
+    },
+    {
+      "id": 2,
+      "order_id": 450789469,
+      "amount": "128.16",
+      "currency": "CAD",
+      "user_id": null,
+      "test": true,
+      "processed_at": "2018-08-11T15:43:39-04:00",
+      "updated_at": "2018-08-09T15:43:41-04:00",
+      "remote_reference": "1118367",
+      "payment_method": "credit_card",
+      "payment_details": {
+        "credit_card_number": "•••• •••• •••• 2",
+        "credit_card_company": "Bogus"
+      }
+    },
+    {
+      "id": 3,
+      "order_id": 450789469,
+      "amount": "28.16",
+      "currency": "CAD",
+      "user_id": null,
+      "test": true,
+      "processed_at": "2018-08-12T15:43:39-04:00",
+      "updated_at": "2018-08-09T15:43:41-04:00",
+      "remote_reference": "1118368",
+      "payment_method": "credit_card",
+      "payment_details": {
+        "credit_card_number": "•••• •••• •••• 3",
+        "credit_card_company": "Bogus"
+      }
+    }
+  ]
+}

+ 18 - 0
test/tender_transaction_test.rb

@@ -0,0 +1,18 @@
+# frozen_string_literal: true
+
+require 'test_helper'
+
+class TenderTransactionTest < Test::Unit::TestCase
+  def setup
+    super
+    fake "tender_transactions", method: :get, body: load_fixture('tender_transactions')
+  end
+
+  context "Tender Transaction" do
+    should 'return a list of transactions' do
+      tender_transactions = ShopifyAPI::TenderTransaction.all
+      assert_equal 3, tender_transactions.length
+      assert_equal [1, 2, 3], tender_transactions.map(&:id)
+    end
+  end
+end