th_shopify_api 1.2.6.pre
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/.gitignore +5 -0
- data/CHANGELOG +57 -0
- data/LICENSE +20 -0
- data/README.rdoc +60 -0
- data/RELEASING +16 -0
- data/Rakefile +41 -0
- data/bin/shopify +4 -0
- data/lib/active_resource/connection_ext.rb +16 -0
- data/lib/shopify_api.rb +18 -0
- data/lib/shopify_api/countable.rb +7 -0
- data/lib/shopify_api/events.rb +7 -0
- data/lib/shopify_api/limits.rb +76 -0
- data/lib/shopify_api/metafields.rb +18 -0
- data/lib/shopify_api/resources.rb +40 -0
- data/lib/shopify_api/resources/address.rb +4 -0
- data/lib/shopify_api/resources/application_charge.rb +9 -0
- data/lib/shopify_api/resources/article.rb +12 -0
- data/lib/shopify_api/resources/asset.rb +95 -0
- data/lib/shopify_api/resources/base.rb +5 -0
- data/lib/shopify_api/resources/billing_address.rb +4 -0
- data/lib/shopify_api/resources/blog.rb +10 -0
- data/lib/shopify_api/resources/cli.rb +161 -0
- data/lib/shopify_api/resources/collect.rb +5 -0
- data/lib/shopify_api/resources/comment.rb +13 -0
- data/lib/shopify_api/resources/countable.rb +7 -0
- data/lib/shopify_api/resources/country.rb +4 -0
- data/lib/shopify_api/resources/custom_collection.rb +19 -0
- data/lib/shopify_api/resources/customer.rb +4 -0
- data/lib/shopify_api/resources/customer_group.rb +4 -0
- data/lib/shopify_api/resources/event.rb +10 -0
- data/lib/shopify_api/resources/fulfillment.rb +5 -0
- data/lib/shopify_api/resources/image.rb +16 -0
- data/lib/shopify_api/resources/line_item.rb +4 -0
- data/lib/shopify_api/resources/metafield.rb +15 -0
- data/lib/shopify_api/resources/note_attribute.rb +4 -0
- data/lib/shopify_api/resources/option.rb +4 -0
- data/lib/shopify_api/resources/order.rb +25 -0
- data/lib/shopify_api/resources/page.rb +6 -0
- data/lib/shopify_api/resources/payment_details.rb +4 -0
- data/lib/shopify_api/resources/product.rb +33 -0
- data/lib/shopify_api/resources/product_search_engine.rb +4 -0
- data/lib/shopify_api/resources/province.rb +5 -0
- data/lib/shopify_api/resources/receipt.rb +4 -0
- data/lib/shopify_api/resources/recurring_application_charge.rb +23 -0
- data/lib/shopify_api/resources/redirect.rb +4 -0
- data/lib/shopify_api/resources/rule.rb +4 -0
- data/lib/shopify_api/resources/script_tag.rb +4 -0
- data/lib/shopify_api/resources/shipping_address.rb +4 -0
- data/lib/shopify_api/resources/shipping_line.rb +4 -0
- data/lib/shopify_api/resources/shop.rb +23 -0
- data/lib/shopify_api/resources/smart_collection.rb +10 -0
- data/lib/shopify_api/resources/tax_line.rb +4 -0
- data/lib/shopify_api/resources/theme.rb +4 -0
- data/lib/shopify_api/resources/transaction.rb +5 -0
- data/lib/shopify_api/resources/variant.rb +11 -0
- data/lib/shopify_api/resources/webhook.rb +4 -0
- data/lib/shopify_api/session.rb +166 -0
- data/shopify_api.gemspec +35 -0
- data/test/cli_test.rb +109 -0
- data/test/limits_test.rb +37 -0
- data/test/order_test.rb +48 -0
- data/test/shopify_api_test.rb +55 -0
- data/test/test_helper.rb +29 -0
- metadata +153 -0
data/test/order_test.rb
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class OrderTest < Test::Unit::TestCase
|
4
|
+
def setup
|
5
|
+
ActiveResource::Base.site = "http://localhost"
|
6
|
+
end
|
7
|
+
|
8
|
+
context "Order" do
|
9
|
+
context "#note_attributes" do
|
10
|
+
|
11
|
+
should "be loaded correctly from order xml" do
|
12
|
+
order_xml = <<-XML
|
13
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
14
|
+
<order>
|
15
|
+
<note-attributes type="array">
|
16
|
+
<note-attribute>
|
17
|
+
<name>size</name>
|
18
|
+
<value>large</value>
|
19
|
+
</note-attribute>
|
20
|
+
</note-attributes>
|
21
|
+
</order>
|
22
|
+
XML
|
23
|
+
|
24
|
+
order = ShopifyAPI::Order.new(Hash.from_xml(order_xml)["order"])
|
25
|
+
|
26
|
+
assert_equal 1, order.note_attributes.size
|
27
|
+
|
28
|
+
note_attribute = order.note_attributes.first
|
29
|
+
assert_equal "size", note_attribute.name
|
30
|
+
assert_equal "large", note_attribute.value
|
31
|
+
end
|
32
|
+
|
33
|
+
should "be able to add note attributes to an order" do
|
34
|
+
order = ShopifyAPI::Order.new
|
35
|
+
order.note_attributes = []
|
36
|
+
order.note_attributes << ShopifyAPI::NoteAttribute.new(:name => "color", :value => "blue")
|
37
|
+
|
38
|
+
order_xml = Hash.from_xml(order.to_xml)
|
39
|
+
assert note_attributes = order_xml["order"]["note_attributes"]
|
40
|
+
assert_instance_of Array, note_attributes
|
41
|
+
|
42
|
+
attribute = note_attributes.first
|
43
|
+
assert_equal "color", attribute["name"]
|
44
|
+
assert_equal "blue", attribute["value"]
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class ShopifyApiTest < Test::Unit::TestCase
|
4
|
+
|
5
|
+
context "Session" do
|
6
|
+
should "not be valid without a url" do
|
7
|
+
session = ShopifyAPI::Session.new(nil, "any-token")
|
8
|
+
assert_not session.valid?
|
9
|
+
end
|
10
|
+
|
11
|
+
should "not be valid without token" do
|
12
|
+
session = ShopifyAPI::Session.new("testshop.myshopify.com")
|
13
|
+
assert_not session.valid?
|
14
|
+
end
|
15
|
+
|
16
|
+
should "be valid with any token and any url" do
|
17
|
+
session = ShopifyAPI::Session.new("testshop.myshopify.com", "any-token")
|
18
|
+
assert session.valid?
|
19
|
+
end
|
20
|
+
|
21
|
+
should "not raise error without params" do
|
22
|
+
assert_nothing_raised do
|
23
|
+
session = ShopifyAPI::Session.new("testshop.myshopify.com", "any-token")
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
should "raise error if params passed but signature omitted" do
|
28
|
+
assert_raises(RuntimeError) do
|
29
|
+
session = ShopifyAPI::Session.new("testshop.myshopify.com", "any-token", {'foo' => 'bar'})
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
should "setup api_key and secret for all sessions" do
|
34
|
+
ShopifyAPI::Session.setup(:api_key => "My test key", :secret => "My test secret")
|
35
|
+
assert_equal "My test key", ShopifyAPI::Session.api_key
|
36
|
+
assert_equal "My test secret", ShopifyAPI::Session.secret
|
37
|
+
end
|
38
|
+
|
39
|
+
should "use 'https' protocol by default for all sessions" do
|
40
|
+
assert_equal 'https', ShopifyAPI::Session.protocol
|
41
|
+
end
|
42
|
+
|
43
|
+
should "#temp reset ShopifyAPI::Base.site to original value" do
|
44
|
+
ShopifyAPI::Base.site = 'http://www.original.com'
|
45
|
+
|
46
|
+
ShopifyAPI::Session.setup(:api_key => "key", :secret => "secret")
|
47
|
+
assigned_site = nil
|
48
|
+
ShopifyAPI::Session.temp("testshop.myshopify.com", "any-token") {
|
49
|
+
assigned_site = ShopifyAPI::Base.site
|
50
|
+
}
|
51
|
+
assert_equal 'https://key:e56d5793b869753d87cf03ceb6bb5dfc@testshop.myshopify.com/admin', assigned_site.to_s
|
52
|
+
assert_equal 'http://www.original.com', ShopifyAPI::Base.site.to_s
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
data/test/test_helper.rb
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'test/unit'
|
3
|
+
require 'mocha'
|
4
|
+
|
5
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
6
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
7
|
+
require 'shopify_api'
|
8
|
+
|
9
|
+
# setup ShopifyAPI with fake api_key and secret
|
10
|
+
ShopifyAPI::Session.setup(:api_key => "API Test key", :secret => "API Test secret")
|
11
|
+
|
12
|
+
class Test::Unit::TestCase
|
13
|
+
def self.test(string, &block)
|
14
|
+
define_method("test:#{string}", &block)
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.should(string, &block)
|
18
|
+
self.test("should_#{string}", &block)
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.context(string)
|
22
|
+
yield
|
23
|
+
end
|
24
|
+
|
25
|
+
# Custom Assertions
|
26
|
+
def assert_not(expression)
|
27
|
+
assert_block("Expected <#{expression}> to be false!") { not expression }
|
28
|
+
end
|
29
|
+
end
|
metadata
ADDED
@@ -0,0 +1,153 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: th_shopify_api
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.2.6.pre
|
5
|
+
prerelease: 6
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- TravisHaynes
|
9
|
+
- Shopify
|
10
|
+
autorequire:
|
11
|
+
bindir: bin
|
12
|
+
cert_chain: []
|
13
|
+
date: 2011-09-10 00:00:00.000000000Z
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: activeresource
|
17
|
+
requirement: &16692540 !ruby/object:Gem::Requirement
|
18
|
+
none: false
|
19
|
+
requirements:
|
20
|
+
- - ! '>='
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 2.2.2
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: *16692540
|
26
|
+
- !ruby/object:Gem::Dependency
|
27
|
+
name: thor
|
28
|
+
requirement: &16691800 !ruby/object:Gem::Requirement
|
29
|
+
none: false
|
30
|
+
requirements:
|
31
|
+
- - ! '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 0.14.4
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: *16691800
|
37
|
+
- !ruby/object:Gem::Dependency
|
38
|
+
name: mocha
|
39
|
+
requirement: &16691100 !ruby/object:Gem::Requirement
|
40
|
+
none: false
|
41
|
+
requirements:
|
42
|
+
- - ! '>='
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
version: 0.9.8
|
45
|
+
type: :development
|
46
|
+
prerelease: false
|
47
|
+
version_requirements: *16691100
|
48
|
+
description: The Shopify API gem allows Ruby developers to programmatically access
|
49
|
+
the admin section of Shopify stores. The API is implemented as XML over HTTP using
|
50
|
+
all four verbs (GET/POST/PUT/DELETE). Each resource, like Order, Product, or Collection,
|
51
|
+
has its own URL and is manipulated in isolation.
|
52
|
+
email:
|
53
|
+
- travis.j.haynes@gmail.com
|
54
|
+
- developers@jadedpixel.com
|
55
|
+
executables:
|
56
|
+
- shopify
|
57
|
+
extensions: []
|
58
|
+
extra_rdoc_files:
|
59
|
+
- LICENSE
|
60
|
+
- README.rdoc
|
61
|
+
files:
|
62
|
+
- .document
|
63
|
+
- .gitignore
|
64
|
+
- CHANGELOG
|
65
|
+
- LICENSE
|
66
|
+
- README.rdoc
|
67
|
+
- RELEASING
|
68
|
+
- Rakefile
|
69
|
+
- bin/shopify
|
70
|
+
- lib/active_resource/connection_ext.rb
|
71
|
+
- lib/shopify_api.rb
|
72
|
+
- lib/shopify_api/countable.rb
|
73
|
+
- lib/shopify_api/events.rb
|
74
|
+
- lib/shopify_api/limits.rb
|
75
|
+
- lib/shopify_api/metafields.rb
|
76
|
+
- lib/shopify_api/resources.rb
|
77
|
+
- lib/shopify_api/resources/address.rb
|
78
|
+
- lib/shopify_api/resources/application_charge.rb
|
79
|
+
- lib/shopify_api/resources/article.rb
|
80
|
+
- lib/shopify_api/resources/asset.rb
|
81
|
+
- lib/shopify_api/resources/base.rb
|
82
|
+
- lib/shopify_api/resources/billing_address.rb
|
83
|
+
- lib/shopify_api/resources/blog.rb
|
84
|
+
- lib/shopify_api/resources/cli.rb
|
85
|
+
- lib/shopify_api/resources/collect.rb
|
86
|
+
- lib/shopify_api/resources/comment.rb
|
87
|
+
- lib/shopify_api/resources/countable.rb
|
88
|
+
- lib/shopify_api/resources/country.rb
|
89
|
+
- lib/shopify_api/resources/custom_collection.rb
|
90
|
+
- lib/shopify_api/resources/customer.rb
|
91
|
+
- lib/shopify_api/resources/customer_group.rb
|
92
|
+
- lib/shopify_api/resources/event.rb
|
93
|
+
- lib/shopify_api/resources/fulfillment.rb
|
94
|
+
- lib/shopify_api/resources/image.rb
|
95
|
+
- lib/shopify_api/resources/line_item.rb
|
96
|
+
- lib/shopify_api/resources/metafield.rb
|
97
|
+
- lib/shopify_api/resources/note_attribute.rb
|
98
|
+
- lib/shopify_api/resources/option.rb
|
99
|
+
- lib/shopify_api/resources/order.rb
|
100
|
+
- lib/shopify_api/resources/page.rb
|
101
|
+
- lib/shopify_api/resources/payment_details.rb
|
102
|
+
- lib/shopify_api/resources/product.rb
|
103
|
+
- lib/shopify_api/resources/product_search_engine.rb
|
104
|
+
- lib/shopify_api/resources/province.rb
|
105
|
+
- lib/shopify_api/resources/receipt.rb
|
106
|
+
- lib/shopify_api/resources/recurring_application_charge.rb
|
107
|
+
- lib/shopify_api/resources/redirect.rb
|
108
|
+
- lib/shopify_api/resources/rule.rb
|
109
|
+
- lib/shopify_api/resources/script_tag.rb
|
110
|
+
- lib/shopify_api/resources/shipping_address.rb
|
111
|
+
- lib/shopify_api/resources/shipping_line.rb
|
112
|
+
- lib/shopify_api/resources/shop.rb
|
113
|
+
- lib/shopify_api/resources/smart_collection.rb
|
114
|
+
- lib/shopify_api/resources/tax_line.rb
|
115
|
+
- lib/shopify_api/resources/theme.rb
|
116
|
+
- lib/shopify_api/resources/transaction.rb
|
117
|
+
- lib/shopify_api/resources/variant.rb
|
118
|
+
- lib/shopify_api/resources/webhook.rb
|
119
|
+
- lib/shopify_api/session.rb
|
120
|
+
- shopify_api.gemspec
|
121
|
+
- test/cli_test.rb
|
122
|
+
- test/limits_test.rb
|
123
|
+
- test/order_test.rb
|
124
|
+
- test/shopify_api_test.rb
|
125
|
+
- test/test_helper.rb
|
126
|
+
homepage: http://www.shopify.com/partners/apps
|
127
|
+
licenses:
|
128
|
+
- MIT
|
129
|
+
post_install_message:
|
130
|
+
rdoc_options:
|
131
|
+
- --charset=UTF-8
|
132
|
+
require_paths:
|
133
|
+
- lib
|
134
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
135
|
+
none: false
|
136
|
+
requirements:
|
137
|
+
- - ! '>='
|
138
|
+
- !ruby/object:Gem::Version
|
139
|
+
version: '0'
|
140
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
141
|
+
none: false
|
142
|
+
requirements:
|
143
|
+
- - ! '>'
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: 1.3.1
|
146
|
+
requirements: []
|
147
|
+
rubyforge_project:
|
148
|
+
rubygems_version: 1.8.8
|
149
|
+
signing_key:
|
150
|
+
specification_version: 3
|
151
|
+
summary: The Shopify API gem is a lightweight gem for accessing the Shopify admin
|
152
|
+
REST web services
|
153
|
+
test_files: []
|