Browse Source

Adding support for CarrierService resource

Ben Cox 11 years ago
parent
commit
af64fb01b2

+ 4 - 0
CHANGELOG

@@ -1,3 +1,7 @@
+== Version 3.2.1 (Unreleased)
+
+* Added CarrierService resource
+
 == Version 3.2.0
 
 * in Session::request_token params is no longer optional, you must pass all the params and the method will now extract the code

+ 4 - 0
lib/shopify_api/resources/carrier_service.rb

@@ -0,0 +1,4 @@
+module ShopifyAPI
+  class CarrierService < Base
+  end
+end

+ 17 - 0
test/carrier_service_test.rb

@@ -0,0 +1,17 @@
+require 'test_helper'
+
+class CarrierServiceTest < Test::Unit::TestCase
+  test 'new should create carrier service' do
+    fake "carrier_services", :method => :post, :body => load_fixture('carrier_service')
+    carrier_service = ShopifyAPI::CarrierService.new(:name => "Some Postal Service")
+    carrier_service.save
+    assert_equal "Some Postal Service" , carrier_service.name
+  end
+
+  test 'find should return the carrier service' do
+    fake "carrier_services/123456", :method => :get, :body => load_fixture('carrier_service')
+    carrier_service = ShopifyAPI::CarrierService.find(123456)
+    assert_equal 123456 , carrier_service.id
+    assert_equal "Some Postal Service", carrier_service.name
+  end
+end

+ 9 - 0
test/fixtures/carrier_service.json

@@ -0,0 +1,9 @@
+{
+  "carrier_service": {
+    "name": "Some Postal Service",
+    "id": 123456,
+    "callback_url": "http://google.com",
+    "format": "json",
+    "service_discovery": true
+  }
+}