shopify_api 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.0
1
+ 1.0.1
@@ -120,6 +120,7 @@ module ShopifyAPI
120
120
  end
121
121
 
122
122
  def initialize(url, token = nil, params = nil)
123
+ raise ArgumentError, "A valid Shopify shop URL must be provided" if url.blank?
123
124
  self.url, self.token = url, token
124
125
 
125
126
  if params && params[:signature]
@@ -1,13 +1,71 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
1
4
  # -*- encoding: utf-8 -*-
2
5
 
3
6
  Gem::Specification.new do |s|
4
7
  s.name = %q{shopify_api}
5
- s.version = "1.0.0"
8
+ s.version = "1.0.1"
6
9
 
7
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
- s.authors = ["Tobias Lütke", "Cody Fauser", "Dennis Theisen"]
9
- s.date = %q{2009-06-15}
10
- s.description = %q{= Shopify API The Shopify API gem allows Ruby developers to programmatically access the admin section of Shopify stores. The API is implemented as XML over HTTP using all four verbs (GET/POST/PUT/DELETE). Each resource, like Order, Product, or Collection, has its own URL and is manipulated in isolation. In other words, we’ve tried to make the API follow the REST principles as much as possible. == Usage === Requirements All API usage happens through Shopify applications, created by either shop owners for their own shops, or by Shopify Partners for use by shop owners: * Shop owners can create applications for themselves through their own admin (under the Preferences > Applications tab). * Shopify Partners create applications through their admin. For more information and detailed documentation visit http://api.shopify.com === Getting Started ShopifyAPI uses ActiveResource to communicate with the REST web service. ActiveResource has to be configured with a fully authorized URL of a particular store first. To obtain that URL you can follow these steps: 1. First create a new application in either the partners admin or your store admin and write down your API_KEY and SHARED_SECRET. 2. You will need to supply two parameters to the Session class before you instantiate it: ShopifyAPI::Session.setup({:api_key => API_KEY, :secret => SHARED_SECRET}) 3. Create a new Session for a specific shop. That session is not fully valid yet, but it can be used to create a URL that you will redirect your users to: session = ShopifyAPI::Session.new("yourshopname.myshopify.com") session.valid? # returns false 4. To access the API shop owners need a "token" from that specific shop. In order to get this token they need to authorize with that shop first. The URL to redirect your user to can be generated via: url = session.create_permission_url 5. After visiting this URL, the shop redirects the owner to a custom URL of your application where the "token" gets sent to (it's param name is just "t"). Use that token to instantiate a "valid" session, that is ready to make calls to that particular shop. token = params[:t] session = ShopifyAPI::Session.new("yourshopname.myshopify.com", token) session.valid? # returns true 6. Now you can finally get the fully authorized URL for that shop. Use that URL to configure ActiveResource and you're set: ActiveResource::Base.site = session.site 7. Get data from that shop (returns ActiveResource instances): shop = ShopifyAPI::Shop.current latest_orders = ShopifyAPI::Order.find(:all) == Copyright Copyright (c) 2009 "JadedPixel inc.". See LICENSE for details.}
11
+ s.authors = ["Tobias L\303\274tke", "Cody Fauser", "Dennis Theisen"]
12
+ s.date = %q{2009-12-08}
13
+ s.description = %q{= Shopify API
14
+
15
+ The Shopify API gem allows Ruby developers to programmatically access the admin section of Shopify stores.
16
+
17
+ The API is implemented as XML over HTTP using all four verbs (GET/POST/PUT/DELETE). Each resource, like Order, Product, or Collection, has its own URL and is manipulated in isolation. In other words, we’ve tried to make the API follow the REST principles as much as possible.
18
+
19
+
20
+ == Usage
21
+
22
+ === Requirements
23
+
24
+ All API usage happens through Shopify applications, created by either shop owners for their own shops, or by Shopify Partners for use by other shop owners:
25
+
26
+ * Shop owners can create applications for themselves through their own admin (under the Preferences > Applications tab).
27
+ * Shopify Partners create applications through their admin: http://app.shopify.com/services/partners
28
+
29
+ For more information and detailed documentation about the API visit http://api.shopify.com
30
+
31
+ === Getting Started
32
+
33
+ ShopifyAPI uses ActiveResource to communicate with the REST web service. ActiveResource has to be configured with a fully authorized URL of a particular store first. To obtain that URL you can follow these steps:
34
+
35
+ 1. First create a new application in either the partners admin or your store admin and write down your API_KEY and SHARED_SECRET.
36
+
37
+ 2. You will need to supply two parameters to the Session class before you instantiate it:
38
+
39
+ ShopifyAPI::Session.setup({:api_key => API_KEY, :secret => SHARED_SECRET})
40
+
41
+ 3. Create a new Session for a specific shop. That session is not fully valid yet, but it can be used to create a URL that you will redirect your users to:
42
+
43
+ session = ShopifyAPI::Session.new("yourshopname.myshopify.com")
44
+ session.valid? # returns false
45
+
46
+ 4. To access the API shop owners need a "token" from that specific shop. In order to get this token they need to authorize with that shop first. The URL to redirect your user to can be generated via:
47
+
48
+ url = session.create_permission_url
49
+
50
+ 5. After visiting this URL, the shop redirects the owner to a custom URL of your application where the "token" gets sent to (it's param name is just "t"). Use that token to instantiate a "valid" session, that is ready to make calls to that particular shop.
51
+
52
+ token = params[:t]
53
+ session = ShopifyAPI::Session.new("yourshopname.myshopify.com", token)
54
+ session.valid? # returns true
55
+
56
+ 6. Now you can finally get the fully authorized URL for that shop. Use that URL to configure ActiveResource and you're set:
57
+
58
+ ActiveResource::Base.site = session.site
59
+
60
+ 7. Get data from that shop (returns ActiveResource instances):
61
+
62
+ shop = ShopifyAPI::Shop.current
63
+ latest_orders = ShopifyAPI::Order.find(:all)
64
+
65
+ == Copyright
66
+
67
+ Copyright (c) 2009 "JadedPixel inc.". See LICENSE for details.
68
+ }
11
69
  s.email = %q{developers@jadedpixel.com}
12
70
  s.extra_rdoc_files = [
13
71
  "LICENSE",
@@ -23,24 +81,25 @@ Gem::Specification.new do |s|
23
81
  "VERSION",
24
82
  "lib/shopify_api.rb",
25
83
  "shopify_api.gemspec",
84
+ "test/order_test.rb",
26
85
  "test/shopify_api_test.rb",
27
86
  "test/test_helper.rb"
28
87
  ]
29
- s.has_rdoc = true
30
88
  s.homepage = %q{http://github.com/Shopify/shopify_api}
31
89
  s.rdoc_options = ["--charset=UTF-8"]
32
90
  s.require_paths = ["lib"]
33
91
  s.rubyforge_project = %q{shopify-api}
34
- s.rubygems_version = %q{1.3.1}
92
+ s.rubygems_version = %q{1.3.5}
35
93
  s.summary = %q{ShopifyAPI is a lightweight gem for accessing the Shopify admin REST web services}
36
94
  s.test_files = [
37
- "test/shopify_api_test.rb",
95
+ "test/order_test.rb",
96
+ "test/shopify_api_test.rb",
38
97
  "test/test_helper.rb"
39
98
  ]
40
99
 
41
100
  if s.respond_to? :specification_version then
42
101
  current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
43
- s.specification_version = 2
102
+ s.specification_version = 3
44
103
 
45
104
  if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
46
105
  s.add_runtime_dependency(%q<activeresource>, [">= 2.2.2"])
@@ -51,3 +110,4 @@ Gem::Specification.new do |s|
51
110
  s.add_dependency(%q<activeresource>, [">= 2.2.2"])
52
111
  end
53
112
  end
113
+
@@ -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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shopify_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - "Tobias L\xC3\xBCtke"
@@ -11,7 +11,7 @@ autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
13
 
14
- date: 2009-06-15 00:00:00 -04:00
14
+ date: 2009-12-08 00:00:00 -05:00
15
15
  default_executable:
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
@@ -24,7 +24,26 @@ dependencies:
24
24
  - !ruby/object:Gem::Version
25
25
  version: 2.2.2
26
26
  version:
27
- description: "= Shopify API The Shopify API gem allows Ruby developers to programmatically access the admin section of Shopify stores. The API is implemented as XML over HTTP using all four verbs (GET/POST/PUT/DELETE). Each resource, like Order, Product, or Collection, has its own URL and is manipulated in isolation. In other words, we\xE2\x80\x99ve tried to make the API follow the REST principles as much as possible. == Usage === Requirements All API usage happens through Shopify applications, created by either shop owners for their own shops, or by Shopify Partners for use by shop owners: * Shop owners can create applications for themselves through their own admin (under the Preferences > Applications tab). * Shopify Partners create applications through their admin. For more information and detailed documentation visit http://api.shopify.com === Getting Started ShopifyAPI uses ActiveResource to communicate with the REST web service. ActiveResource has to be configured with a fully authorized URL of a particular store first. To obtain that URL you can follow these steps: 1. First create a new application in either the partners admin or your store admin and write down your API_KEY and SHARED_SECRET. 2. You will need to supply two parameters to the Session class before you instantiate it: ShopifyAPI::Session.setup({:api_key => API_KEY, :secret => SHARED_SECRET}) 3. Create a new Session for a specific shop. That session is not fully valid yet, but it can be used to create a URL that you will redirect your users to: session = ShopifyAPI::Session.new(\"yourshopname.myshopify.com\") session.valid? # returns false 4. To access the API shop owners need a \"token\" from that specific shop. In order to get this token they need to authorize with that shop first. The URL to redirect your user to can be generated via: url = session.create_permission_url 5. After visiting this URL, the shop redirects the owner to a custom URL of your application where the \"token\" gets sent to (it's param name is just \"t\"). Use that token to instantiate a \"valid\" session, that is ready to make calls to that particular shop. token = params[:t] session = ShopifyAPI::Session.new(\"yourshopname.myshopify.com\", token) session.valid? # returns true 6. Now you can finally get the fully authorized URL for that shop. Use that URL to configure ActiveResource and you're set: ActiveResource::Base.site = session.site 7. Get data from that shop (returns ActiveResource instances): shop = ShopifyAPI::Shop.current latest_orders = ShopifyAPI::Order.find(:all) == Copyright Copyright (c) 2009 \"JadedPixel inc.\". See LICENSE for details."
27
+ description: "= Shopify API\n\n\
28
+ The Shopify API gem allows Ruby developers to programmatically access the admin section of Shopify stores.\n\n\
29
+ The API is implemented as XML over HTTP using all four verbs (GET/POST/PUT/DELETE). Each resource, like Order, Product, or Collection, has its own URL and is manipulated in isolation. In other words, we\xE2\x80\x99ve tried to make the API follow the REST principles as much as possible.\n\n\n\
30
+ == Usage\n\n\
31
+ === Requirements\n\n\
32
+ All API usage happens through Shopify applications, created by either shop owners for their own shops, or by Shopify Partners for use by other shop owners:\n\n\
33
+ * Shop owners can create applications for themselves through their own admin (under the Preferences > Applications tab).\n\
34
+ * Shopify Partners create applications through their admin: http://app.shopify.com/services/partners \n\n\
35
+ For more information and detailed documentation about the API visit http://api.shopify.com\n\n\
36
+ === Getting Started\n\n\
37
+ ShopifyAPI uses ActiveResource to communicate with the REST web service. ActiveResource has to be configured with a fully authorized URL of a particular store first. To obtain that URL you can follow these steps:\n\n\
38
+ 1. First create a new application in either the partners admin or your store admin and write down your API_KEY and SHARED_SECRET.\n\n\
39
+ 2. You will need to supply two parameters to the Session class before you instantiate it:\n\n ShopifyAPI::Session.setup({:api_key => API_KEY, :secret => SHARED_SECRET})\n\n\
40
+ 3. Create a new Session for a specific shop. That session is not fully valid yet, but it can be used to create a URL that you will redirect your users to:\n\n session = ShopifyAPI::Session.new(\"yourshopname.myshopify.com\")\n session.valid? # returns false\n\n\
41
+ 4. To access the API shop owners need a \"token\" from that specific shop. In order to get this token they need to authorize with that shop first. The URL to redirect your user to can be generated via:\n\n url = session.create_permission_url\n\n\
42
+ 5. After visiting this URL, the shop redirects the owner to a custom URL of your application where the \"token\" gets sent to (it's param name is just \"t\"). Use that token to instantiate a \"valid\" session, that is ready to make calls to that particular shop.\n\n token = params[:t]\n session = ShopifyAPI::Session.new(\"yourshopname.myshopify.com\", token)\n session.valid? # returns true\n\n\
43
+ 6. Now you can finally get the fully authorized URL for that shop. Use that URL to configure ActiveResource and you're set:\n\n ActiveResource::Base.site = session.site\n\n\
44
+ 7. Get data from that shop (returns ActiveResource instances):\n\n shop = ShopifyAPI::Shop.current\n latest_orders = ShopifyAPI::Order.find(:all)\n\n\
45
+ == Copyright\n\n\
46
+ Copyright (c) 2009 \"JadedPixel inc.\". See LICENSE for details.\n"
28
47
  email: developers@jadedpixel.com
29
48
  executables: []
30
49
 
@@ -43,6 +62,7 @@ files:
43
62
  - VERSION
44
63
  - lib/shopify_api.rb
45
64
  - shopify_api.gemspec
65
+ - test/order_test.rb
46
66
  - test/shopify_api_test.rb
47
67
  - test/test_helper.rb
48
68
  has_rdoc: true
@@ -71,8 +91,9 @@ requirements: []
71
91
  rubyforge_project: shopify-api
72
92
  rubygems_version: 1.3.5
73
93
  signing_key:
74
- specification_version: 2
94
+ specification_version: 3
75
95
  summary: ShopifyAPI is a lightweight gem for accessing the Shopify admin REST web services
76
96
  test_files:
97
+ - test/order_test.rb
77
98
  - test/shopify_api_test.rb
78
99
  - test/test_helper.rb