magento-rb 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.document +5 -0
- data/Gemfile +20 -0
- data/Gemfile.lock +67 -0
- data/LICENSE.txt +20 -0
- data/README.rdoc +48 -0
- data/Rakefile +53 -0
- data/VERSION +1 -0
- data/lib/magento/savon.rb +48 -0
- data/lib/magento/soap_api_v2.rb +83 -0
- data/lib/magento/xml_api.rb +95 -0
- data/lib/magento-rb.rb +39 -0
- data/magento-rb.gemspec +68 -0
- data/test/helper.rb +18 -0
- data/test/test_magento-rb.rb +7 -0
- metadata +169 -0
data/.document
ADDED
data/Gemfile
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
ruby '1.8.7'
|
|
2
|
+
|
|
3
|
+
source "http://rubygems.org"
|
|
4
|
+
# Add dependencies required to use your gem here.
|
|
5
|
+
# Example:
|
|
6
|
+
# gem "activesupport", ">= 2.3.5"
|
|
7
|
+
|
|
8
|
+
gem "rack", "1.6.5"
|
|
9
|
+
|
|
10
|
+
# Add dependencies to develop your gem here.
|
|
11
|
+
# Include everything needed to run rake, tests, features, etc.
|
|
12
|
+
group :development do
|
|
13
|
+
gem "shoulda", ">= 0"
|
|
14
|
+
gem "rdoc", "~> 3.12"
|
|
15
|
+
gem "bundler", "1.14.5"
|
|
16
|
+
gem "jeweler", "~> 1.8.3"
|
|
17
|
+
gem "simplecov", ">= 0"
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
gem "savon", "2.3.0"
|
data/Gemfile.lock
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
GEM
|
|
2
|
+
remote: http://rubygems.org/
|
|
3
|
+
specs:
|
|
4
|
+
akami (1.2.2)
|
|
5
|
+
gyoku (>= 0.4.0)
|
|
6
|
+
nokogiri
|
|
7
|
+
builder (3.2.3)
|
|
8
|
+
git (1.2.5)
|
|
9
|
+
gyoku (1.1.1)
|
|
10
|
+
builder (>= 2.1.2)
|
|
11
|
+
httpi (2.1.1)
|
|
12
|
+
rack
|
|
13
|
+
rubyntlm (~> 0.3.2)
|
|
14
|
+
jeweler (1.8.3)
|
|
15
|
+
bundler (~> 1.0)
|
|
16
|
+
git (>= 1.2.5)
|
|
17
|
+
rake
|
|
18
|
+
rdoc
|
|
19
|
+
json (1.7.3)
|
|
20
|
+
mime-types (1.25.1)
|
|
21
|
+
multi_json (1.3.6)
|
|
22
|
+
nokogiri (1.5.11)
|
|
23
|
+
nori (2.3.0)
|
|
24
|
+
rack (1.6.5)
|
|
25
|
+
rake (0.9.2.2)
|
|
26
|
+
rdoc (3.12)
|
|
27
|
+
json (~> 1.4)
|
|
28
|
+
rubyntlm (0.3.4)
|
|
29
|
+
savon (2.3.0)
|
|
30
|
+
akami (~> 1.2.0)
|
|
31
|
+
builder (>= 2.1.2)
|
|
32
|
+
gyoku (~> 1.1.0)
|
|
33
|
+
httpi (~> 2.1.0)
|
|
34
|
+
nokogiri (>= 1.4.0, < 1.6)
|
|
35
|
+
nori (~> 2.3.0)
|
|
36
|
+
wasabi (~> 3.2.0)
|
|
37
|
+
shoulda (3.0.1)
|
|
38
|
+
shoulda-context (~> 1.0.0)
|
|
39
|
+
shoulda-matchers (~> 1.0.0)
|
|
40
|
+
shoulda-context (1.0.0)
|
|
41
|
+
shoulda-matchers (1.0.0)
|
|
42
|
+
simplecov (0.6.4)
|
|
43
|
+
multi_json (~> 1.0)
|
|
44
|
+
simplecov-html (~> 0.5.3)
|
|
45
|
+
simplecov-html (0.5.3)
|
|
46
|
+
wasabi (3.2.3)
|
|
47
|
+
httpi (~> 2.0)
|
|
48
|
+
mime-types (< 2.0.0)
|
|
49
|
+
nokogiri (>= 1.4.0)
|
|
50
|
+
|
|
51
|
+
PLATFORMS
|
|
52
|
+
ruby
|
|
53
|
+
|
|
54
|
+
DEPENDENCIES
|
|
55
|
+
bundler (= 1.14.5)
|
|
56
|
+
jeweler (~> 1.8.3)
|
|
57
|
+
rack (= 1.6.5)
|
|
58
|
+
rdoc (~> 3.12)
|
|
59
|
+
savon (= 2.3.0)
|
|
60
|
+
shoulda
|
|
61
|
+
simplecov
|
|
62
|
+
|
|
63
|
+
RUBY VERSION
|
|
64
|
+
ruby 1.8.7p299
|
|
65
|
+
|
|
66
|
+
BUNDLED WITH
|
|
67
|
+
1.14.5
|
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
Copyright (c) 2012 Joel Van Horn
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
4
|
+
a copy of this software and associated documentation files (the
|
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
9
|
+
the following conditions:
|
|
10
|
+
|
|
11
|
+
The above copyright notice and this permission notice shall be
|
|
12
|
+
included in all copies or substantial portions of the Software.
|
|
13
|
+
|
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
= magento-rb
|
|
2
|
+
|
|
3
|
+
Use Magento's XMLRPC API like this:
|
|
4
|
+
|
|
5
|
+
require "magento-rb"
|
|
6
|
+
options = {
|
|
7
|
+
:debug => true,
|
|
8
|
+
:proxy => http://my.host.name:port,
|
|
9
|
+
:timeout => 90
|
|
10
|
+
}
|
|
11
|
+
xml_api = Magento::XmlApi.new "http://localhost/magento", "username", "api_key", options
|
|
12
|
+
|
|
13
|
+
# Pass in the XMLRPC method name and ID parameter as arguments
|
|
14
|
+
response = xml_api.call("sales_order.info", "123")
|
|
15
|
+
|
|
16
|
+
# Call XMLRPC methods on xml_api directly
|
|
17
|
+
response = xml_api.sales_order_info("123")
|
|
18
|
+
|
|
19
|
+
# Create a new customer
|
|
20
|
+
customer_id = xml_api.customer_create(:email => email)
|
|
21
|
+
|
|
22
|
+
The SOAP API v2 has a similar interface, but it is about 3x slower than XMLRPC and responses are more verbose.
|
|
23
|
+
|
|
24
|
+
== Contributing to magento-rb
|
|
25
|
+
|
|
26
|
+
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
|
|
27
|
+
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
|
|
28
|
+
* Fork the project.
|
|
29
|
+
* Start a feature/bugfix branch.
|
|
30
|
+
* Commit and push until you are happy with your contribution.
|
|
31
|
+
* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
|
|
32
|
+
* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
|
|
33
|
+
|
|
34
|
+
== Thanks
|
|
35
|
+
|
|
36
|
+
Thanks to Guewen Baconnier for his quick start in XMLRPC for Magento:
|
|
37
|
+
|
|
38
|
+
https://gist.github.com/1875404
|
|
39
|
+
|
|
40
|
+
Learned about Savon and some of the basics from here:
|
|
41
|
+
|
|
42
|
+
http://www.polyvision.org/2011/11/02/using-magento-soap-api-with-ruby-and-savon/
|
|
43
|
+
|
|
44
|
+
== Copyright
|
|
45
|
+
|
|
46
|
+
Copyright (c) 2012 Joel Van Horn. See LICENSE.txt for
|
|
47
|
+
further details.
|
|
48
|
+
|
data/Rakefile
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
3
|
+
require 'rubygems'
|
|
4
|
+
require 'bundler'
|
|
5
|
+
begin
|
|
6
|
+
Bundler.setup(:default, :development)
|
|
7
|
+
rescue Bundler::BundlerError => e
|
|
8
|
+
$stderr.puts e.message
|
|
9
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
|
10
|
+
exit e.status_code
|
|
11
|
+
end
|
|
12
|
+
require 'rake'
|
|
13
|
+
|
|
14
|
+
require 'jeweler'
|
|
15
|
+
Jeweler::Tasks.new do |gem|
|
|
16
|
+
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
|
|
17
|
+
gem.name = "magento-rb"
|
|
18
|
+
gem.homepage = "http://github.com/joelvh/magento-rb"
|
|
19
|
+
gem.license = "MIT"
|
|
20
|
+
gem.summary = "Magento API libraries and other helpful Ruby code"
|
|
21
|
+
gem.description = "Magento API libraries and other helpful Ruby code"
|
|
22
|
+
gem.email = "joeldvanhorn@gmail.com"
|
|
23
|
+
gem.authors = ["Joel Van Horn"]
|
|
24
|
+
# dependencies defined in Gemfile
|
|
25
|
+
end
|
|
26
|
+
#Jeweler::RubygemsDotOrgTasks.new
|
|
27
|
+
|
|
28
|
+
require 'rake/testtask'
|
|
29
|
+
Rake::TestTask.new(:test) do |test|
|
|
30
|
+
test.libs << 'lib' << 'test'
|
|
31
|
+
test.pattern = 'test/**/test_*.rb'
|
|
32
|
+
test.verbose = true
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
#require 'rcov/rcovtask'
|
|
36
|
+
#Rcov::RcovTask.new do |test|
|
|
37
|
+
# test.libs << 'test'
|
|
38
|
+
# test.pattern = 'test/**/test_*.rb'
|
|
39
|
+
# test.verbose = true
|
|
40
|
+
# test.rcov_opts << '--exclude "gems/*"'
|
|
41
|
+
#end
|
|
42
|
+
|
|
43
|
+
task :default => :test
|
|
44
|
+
|
|
45
|
+
require 'rdoc/task'
|
|
46
|
+
Rake::RDocTask.new do |rdoc|
|
|
47
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
|
48
|
+
|
|
49
|
+
rdoc.rdoc_dir = 'rdoc'
|
|
50
|
+
rdoc.title = "magento-rb #{version}"
|
|
51
|
+
rdoc.rdoc_files.include('README*')
|
|
52
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
|
53
|
+
end
|
data/VERSION
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
0.1.2
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
#
|
|
2
|
+
# Magento API can be found @ http://www.magentocommerce.com/wiki/doc/webservices-api/api
|
|
3
|
+
#
|
|
4
|
+
#
|
|
5
|
+
require 'savon'
|
|
6
|
+
|
|
7
|
+
Savon.configure do |config|
|
|
8
|
+
config.log = false # disable logging
|
|
9
|
+
#config.log_level = :info # changing the log level
|
|
10
|
+
#config.logger = Rails.logger # using the Rails logger
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
client = Savon::Client.new do
|
|
14
|
+
wsdl.document = "#{ENV['MAGENTO_ENDPOINT']}/index.php/api/?wsdl"
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
response = client.request :login do
|
|
18
|
+
soap.body = { :username => ENV['MAGENTO_API_USER'], :apiKey => ENV['MAGENTO_API_KEY'] }
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
if response.success? == false
|
|
22
|
+
puts "login failed"
|
|
23
|
+
#System.exit(0)
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
session = response[:login_response][:login_return];
|
|
27
|
+
|
|
28
|
+
response = client.request :call do
|
|
29
|
+
soap.body = {:session => session, :method => 'catalog_product_attribute_media.list', :sku => '001' }
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
# fetching all products
|
|
33
|
+
if response.success?
|
|
34
|
+
# listing found products
|
|
35
|
+
response[:call_response][:call_return][:item][:item].each do |product|
|
|
36
|
+
puts "-------------------------------------------"
|
|
37
|
+
#product = product[:item]
|
|
38
|
+
product.each do |pkey|
|
|
39
|
+
puts "#{pkey}"
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
#logging out
|
|
45
|
+
response = client.request :endSession do
|
|
46
|
+
soap.body = {:session => session}
|
|
47
|
+
end
|
|
48
|
+
puts response.to_hash
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
require 'savon'
|
|
2
|
+
|
|
3
|
+
module Magento
|
|
4
|
+
class SoapApiV2
|
|
5
|
+
extend Savon::Model
|
|
6
|
+
|
|
7
|
+
def initialize(base_url, api_user, api_key)
|
|
8
|
+
super
|
|
9
|
+
|
|
10
|
+
@api_user = api_user
|
|
11
|
+
@api_key = api_key
|
|
12
|
+
self.class.client.wsdl.document = "#{base_url}/api/v2_soap?wsdl=1"
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def session_id(refresh = false)
|
|
16
|
+
@session_id = nil if refresh
|
|
17
|
+
|
|
18
|
+
unless @session_id
|
|
19
|
+
response = client.request :login, :body => { :username => @api_user, :apiKey => @api_key }
|
|
20
|
+
@session_id = response[:login_response][:login_return]
|
|
21
|
+
end
|
|
22
|
+
@session_id
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def session_request(action, body = {}, &block)
|
|
26
|
+
begin
|
|
27
|
+
# get session ID outside of client#request block because the
|
|
28
|
+
# request object is a singleton for this client and
|
|
29
|
+
# the session_id method may have to make a separate request for the ID
|
|
30
|
+
current_session_id = session_id
|
|
31
|
+
|
|
32
|
+
response = client.request action, :body => body do
|
|
33
|
+
# pass objects to block
|
|
34
|
+
yield soap, wsdl, http, wsse if block
|
|
35
|
+
# add session ID before exiting block
|
|
36
|
+
soap.body ||= {}
|
|
37
|
+
# need to overwrite in case it's an expired session ID
|
|
38
|
+
soap.body[:session] = current_session_id
|
|
39
|
+
soap.body[:order!] = soap.body.keys.delete_if {|item| item == :session }.unshift(:session)
|
|
40
|
+
puts "SOAP BODY:::: #{soap.body}"
|
|
41
|
+
end
|
|
42
|
+
#Savon.config.hooks.select(:model_soap_response).call(response) || response
|
|
43
|
+
# get the response: first child named after the action
|
|
44
|
+
response.to_hash["#{action}_response".to_sym].tap do |response|
|
|
45
|
+
@retries = 0
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
rescue Savon::SOAP::Fault => error
|
|
49
|
+
# 5 = session expired
|
|
50
|
+
# 2 = access denied
|
|
51
|
+
raise error unless error.to_hash[:fault][:faultcode] == "5" && @retries == 0
|
|
52
|
+
puts "SESSION EXPIRED ... TRYING AGAIN"
|
|
53
|
+
@retries = 1
|
|
54
|
+
# refresh session ID
|
|
55
|
+
session_id(true)
|
|
56
|
+
session_request action, body, &block
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
def end_session
|
|
62
|
+
session_request :end_session
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
def method_missing(method, *args, &block)
|
|
66
|
+
class_name = self.class.name.snakecase
|
|
67
|
+
action = method
|
|
68
|
+
action = "#{class_name}_#{method}".to_sym unless client.wsdl.soap_actions.include?(action)
|
|
69
|
+
# Magento's actions turn into customer_customer_create, so this allows for customer_create instead
|
|
70
|
+
action = "#{class_name}_#{class_name}_#{method}".to_sym unless client.wsdl.soap_actions.include?(action)
|
|
71
|
+
action = "#{method.to_s.split('_').first}_#{method}".to_sym unless client.wsdl.soap_actions.include?(action)
|
|
72
|
+
puts "SOAP ACTION? #{action}"
|
|
73
|
+
|
|
74
|
+
if client.wsdl.soap_actions.include?(action)
|
|
75
|
+
body = args.first
|
|
76
|
+
session_request action, body, &block
|
|
77
|
+
else
|
|
78
|
+
super
|
|
79
|
+
end
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
end
|
|
83
|
+
end
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
# Copyright Camptocamp SA 2012
|
|
2
|
+
# License: AGPL (GNU Affero General Public License)[http://www.gnu.org/licenses/agpl-3.0.txt]
|
|
3
|
+
# Author Guewen Baconnier
|
|
4
|
+
#
|
|
5
|
+
# https://gist.github.com/1875404
|
|
6
|
+
#
|
|
7
|
+
# EXAMPLE:
|
|
8
|
+
#
|
|
9
|
+
# magento=MagentoAPI.new(ENV['MAGENTO_ENDPOINT'].dup, ENV['MAGENTO_API_USER'].dup, ENV['MAGENTO_API_KEY'].dup, :debug => true)
|
|
10
|
+
# order_infos = magento.call('sales_order.info', '100011892')
|
|
11
|
+
#
|
|
12
|
+
# magento.call('catalog_product.update', 'SKU', {'meta_description' => 'test'})
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
require "xmlrpc/client"
|
|
16
|
+
require 'pp'
|
|
17
|
+
|
|
18
|
+
XMLRPC::Config::ENABLE_NIL_PARSER = true
|
|
19
|
+
|
|
20
|
+
module Magento
|
|
21
|
+
class XmlApi
|
|
22
|
+
|
|
23
|
+
attr_accessor :url, :api_user, :api_key
|
|
24
|
+
|
|
25
|
+
def initialize(base_url, api_user, api_key, options={})
|
|
26
|
+
@url = "#{base_url}/api/xmlrpc/"
|
|
27
|
+
@api_user = api_user
|
|
28
|
+
@api_key = api_key
|
|
29
|
+
@timeout = options[:timeout] || 60
|
|
30
|
+
@proxy = options[:proxy] || nil
|
|
31
|
+
@debug = options[:debug] || false
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def call(method, *arguments)
|
|
35
|
+
request('call', session_id, method, arguments)
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
# def batch(methods)
|
|
39
|
+
# client.multicall
|
|
40
|
+
# end
|
|
41
|
+
|
|
42
|
+
private
|
|
43
|
+
|
|
44
|
+
def client
|
|
45
|
+
@client ||= XMLRPC::Client.new2(@url,@proxy,@timeout).tap do |client|
|
|
46
|
+
http_debug(@debug)
|
|
47
|
+
client.set_debug
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
def http_debug(active)
|
|
52
|
+
output = active ? $stderr : false
|
|
53
|
+
|
|
54
|
+
XMLRPC::Client.class_eval do
|
|
55
|
+
define_method :set_debug do
|
|
56
|
+
@http.set_debug_output(output)
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
def session_id
|
|
62
|
+
@session_id ||= request('login', @api_user, @api_key)
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
def request(method, *arguments)
|
|
66
|
+
begin
|
|
67
|
+
client.call(method, *arguments).tap do |response|
|
|
68
|
+
@retried = false
|
|
69
|
+
end
|
|
70
|
+
rescue EOFError => error
|
|
71
|
+
|
|
72
|
+
raise error if @retried == true
|
|
73
|
+
|
|
74
|
+
@retried = true
|
|
75
|
+
request(method, *arguments)
|
|
76
|
+
|
|
77
|
+
rescue XMLRPC::FaultException => error
|
|
78
|
+
raise Magento::ApiError.new(error.faultString, error.faultCode, error)
|
|
79
|
+
end
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
def method_missing(method, *args, &block)
|
|
83
|
+
# convert the method name to an XMLRPC action name e.g. "sales_order.list"
|
|
84
|
+
parts = method.to_s.snakecase.split('_')
|
|
85
|
+
action = "#{parts[0..-2].join('_')}.#{parts.last}" if parts.size > 1
|
|
86
|
+
|
|
87
|
+
if action
|
|
88
|
+
call action, *args, &block
|
|
89
|
+
else
|
|
90
|
+
super
|
|
91
|
+
end
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
end
|
|
95
|
+
end
|
data/lib/magento-rb.rb
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
require "magento/api_error"
|
|
2
|
+
require "magento/soap_api_v2"
|
|
3
|
+
require "magento/xml_api"
|
|
4
|
+
|
|
5
|
+
module Magento
|
|
6
|
+
|
|
7
|
+
def self.api_endpoint=(value)
|
|
8
|
+
@@xml_api = nil
|
|
9
|
+
@@soap_api = nil
|
|
10
|
+
@@api_endpoint = value
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def self.api_username=(value)
|
|
14
|
+
@@xml_api = nil
|
|
15
|
+
@@soap_api = nil
|
|
16
|
+
@@api_username = value
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def self.api_password=(value)
|
|
20
|
+
@@xml_api = nil
|
|
21
|
+
@@soap_api = nil
|
|
22
|
+
@@api_password = value
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def self.debug=(value)
|
|
26
|
+
@@xml_api = nil
|
|
27
|
+
@@debug = value
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def self.xml_api(debug = nil)
|
|
31
|
+
@@xml_api = nil if debug
|
|
32
|
+
@@xml_api ||= XmlApi.new @@api_endpoint, @@api_username, @@api_password, :debug => debug || @@debug || false
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def self.soap_api
|
|
36
|
+
@@soap_api ||= SoapApiV2.new @@api_endpoint, @@api_username, @@api_password
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
end
|
data/magento-rb.gemspec
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
# Generated by jeweler
|
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
|
4
|
+
# -*- encoding: utf-8 -*-
|
|
5
|
+
|
|
6
|
+
Gem::Specification.new do |s|
|
|
7
|
+
s.name = "magento-rb"
|
|
8
|
+
s.version = "0.1.2"
|
|
9
|
+
|
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
|
11
|
+
s.authors = ["Joel Van Horn"]
|
|
12
|
+
s.date = "2012-06-08"
|
|
13
|
+
s.description = "Magento API libraries and other helpful Ruby code"
|
|
14
|
+
s.email = "joeldvanhorn@gmail.com"
|
|
15
|
+
s.extra_rdoc_files = [
|
|
16
|
+
"LICENSE.txt",
|
|
17
|
+
"README.rdoc"
|
|
18
|
+
]
|
|
19
|
+
s.files = [
|
|
20
|
+
".document",
|
|
21
|
+
"Gemfile",
|
|
22
|
+
"Gemfile.lock",
|
|
23
|
+
"LICENSE.txt",
|
|
24
|
+
"README.rdoc",
|
|
25
|
+
"Rakefile",
|
|
26
|
+
"VERSION",
|
|
27
|
+
"lib/magento-rb.rb",
|
|
28
|
+
"lib/magento/savon.rb",
|
|
29
|
+
"lib/magento/soap_api_v2.rb",
|
|
30
|
+
"lib/magento/xml_api.rb",
|
|
31
|
+
"magento-rb.gemspec",
|
|
32
|
+
"test/helper.rb",
|
|
33
|
+
"test/test_magento-rb.rb"
|
|
34
|
+
]
|
|
35
|
+
s.homepage = "http://github.com/joelvh/magento-rb"
|
|
36
|
+
s.licenses = ["MIT"]
|
|
37
|
+
s.require_paths = ["lib"]
|
|
38
|
+
s.rubygems_version = "1.8.24"
|
|
39
|
+
s.summary = "Magento API libraries and other helpful Ruby code"
|
|
40
|
+
|
|
41
|
+
if s.respond_to? :specification_version then
|
|
42
|
+
s.specification_version = 3
|
|
43
|
+
|
|
44
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
|
45
|
+
s.add_runtime_dependency(%q<savon>, [">= 0"])
|
|
46
|
+
s.add_development_dependency(%q<shoulda>, [">= 0"])
|
|
47
|
+
s.add_development_dependency(%q<rdoc>, ["~> 3.12"])
|
|
48
|
+
s.add_development_dependency(%q<bundler>, ["~> 1.1.4"])
|
|
49
|
+
s.add_development_dependency(%q<jeweler>, ["~> 1.8.3"])
|
|
50
|
+
s.add_development_dependency(%q<simplecov>, [">= 0"])
|
|
51
|
+
else
|
|
52
|
+
s.add_dependency(%q<savon>, [">= 0"])
|
|
53
|
+
s.add_dependency(%q<shoulda>, [">= 0"])
|
|
54
|
+
s.add_dependency(%q<rdoc>, ["~> 3.12"])
|
|
55
|
+
s.add_dependency(%q<bundler>, ["~> 1.1.4"])
|
|
56
|
+
s.add_dependency(%q<jeweler>, ["~> 1.8.3"])
|
|
57
|
+
s.add_dependency(%q<simplecov>, [">= 0"])
|
|
58
|
+
end
|
|
59
|
+
else
|
|
60
|
+
s.add_dependency(%q<savon>, [">= 0"])
|
|
61
|
+
s.add_dependency(%q<shoulda>, [">= 0"])
|
|
62
|
+
s.add_dependency(%q<rdoc>, ["~> 3.12"])
|
|
63
|
+
s.add_dependency(%q<bundler>, ["~> 1.1.4"])
|
|
64
|
+
s.add_dependency(%q<jeweler>, ["~> 1.8.3"])
|
|
65
|
+
s.add_dependency(%q<simplecov>, [">= 0"])
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
|
data/test/helper.rb
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
require 'rubygems'
|
|
2
|
+
require 'bundler'
|
|
3
|
+
begin
|
|
4
|
+
Bundler.setup(:default, :development)
|
|
5
|
+
rescue Bundler::BundlerError => e
|
|
6
|
+
$stderr.puts e.message
|
|
7
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
|
8
|
+
exit e.status_code
|
|
9
|
+
end
|
|
10
|
+
require 'test/unit'
|
|
11
|
+
require 'shoulda'
|
|
12
|
+
|
|
13
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
|
14
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
|
15
|
+
require 'magento-rb'
|
|
16
|
+
|
|
17
|
+
class Test::Unit::TestCase
|
|
18
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: magento-rb
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
hash: 31
|
|
5
|
+
prerelease:
|
|
6
|
+
segments:
|
|
7
|
+
- 0
|
|
8
|
+
- 1
|
|
9
|
+
- 2
|
|
10
|
+
version: 0.1.2
|
|
11
|
+
platform: ruby
|
|
12
|
+
authors:
|
|
13
|
+
- Joel Van Horn
|
|
14
|
+
autorequire:
|
|
15
|
+
bindir: bin
|
|
16
|
+
cert_chain: []
|
|
17
|
+
|
|
18
|
+
date: 2012-06-08 00:00:00 +03:00
|
|
19
|
+
default_executable:
|
|
20
|
+
dependencies:
|
|
21
|
+
- !ruby/object:Gem::Dependency
|
|
22
|
+
name: savon
|
|
23
|
+
prerelease: false
|
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
|
25
|
+
none: false
|
|
26
|
+
requirements:
|
|
27
|
+
- - ">="
|
|
28
|
+
- !ruby/object:Gem::Version
|
|
29
|
+
hash: 3
|
|
30
|
+
segments:
|
|
31
|
+
- 0
|
|
32
|
+
version: "0"
|
|
33
|
+
type: :runtime
|
|
34
|
+
version_requirements: *id001
|
|
35
|
+
- !ruby/object:Gem::Dependency
|
|
36
|
+
name: shoulda
|
|
37
|
+
prerelease: false
|
|
38
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
|
39
|
+
none: false
|
|
40
|
+
requirements:
|
|
41
|
+
- - ">="
|
|
42
|
+
- !ruby/object:Gem::Version
|
|
43
|
+
hash: 3
|
|
44
|
+
segments:
|
|
45
|
+
- 0
|
|
46
|
+
version: "0"
|
|
47
|
+
type: :development
|
|
48
|
+
version_requirements: *id002
|
|
49
|
+
- !ruby/object:Gem::Dependency
|
|
50
|
+
name: rdoc
|
|
51
|
+
prerelease: false
|
|
52
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
|
53
|
+
none: false
|
|
54
|
+
requirements:
|
|
55
|
+
- - ~>
|
|
56
|
+
- !ruby/object:Gem::Version
|
|
57
|
+
hash: 31
|
|
58
|
+
segments:
|
|
59
|
+
- 3
|
|
60
|
+
- 12
|
|
61
|
+
version: "3.12"
|
|
62
|
+
type: :development
|
|
63
|
+
version_requirements: *id003
|
|
64
|
+
- !ruby/object:Gem::Dependency
|
|
65
|
+
name: bundler
|
|
66
|
+
prerelease: false
|
|
67
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
|
68
|
+
none: false
|
|
69
|
+
requirements:
|
|
70
|
+
- - ~>
|
|
71
|
+
- !ruby/object:Gem::Version
|
|
72
|
+
hash: 27
|
|
73
|
+
segments:
|
|
74
|
+
- 1
|
|
75
|
+
- 1
|
|
76
|
+
- 4
|
|
77
|
+
version: 1.1.4
|
|
78
|
+
type: :development
|
|
79
|
+
version_requirements: *id004
|
|
80
|
+
- !ruby/object:Gem::Dependency
|
|
81
|
+
name: jeweler
|
|
82
|
+
prerelease: false
|
|
83
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
|
84
|
+
none: false
|
|
85
|
+
requirements:
|
|
86
|
+
- - ~>
|
|
87
|
+
- !ruby/object:Gem::Version
|
|
88
|
+
hash: 49
|
|
89
|
+
segments:
|
|
90
|
+
- 1
|
|
91
|
+
- 8
|
|
92
|
+
- 3
|
|
93
|
+
version: 1.8.3
|
|
94
|
+
type: :development
|
|
95
|
+
version_requirements: *id005
|
|
96
|
+
- !ruby/object:Gem::Dependency
|
|
97
|
+
name: simplecov
|
|
98
|
+
prerelease: false
|
|
99
|
+
requirement: &id006 !ruby/object:Gem::Requirement
|
|
100
|
+
none: false
|
|
101
|
+
requirements:
|
|
102
|
+
- - ">="
|
|
103
|
+
- !ruby/object:Gem::Version
|
|
104
|
+
hash: 3
|
|
105
|
+
segments:
|
|
106
|
+
- 0
|
|
107
|
+
version: "0"
|
|
108
|
+
type: :development
|
|
109
|
+
version_requirements: *id006
|
|
110
|
+
description: Magento API libraries and other helpful Ruby code
|
|
111
|
+
email: joeldvanhorn@gmail.com
|
|
112
|
+
executables: []
|
|
113
|
+
|
|
114
|
+
extensions: []
|
|
115
|
+
|
|
116
|
+
extra_rdoc_files:
|
|
117
|
+
- LICENSE.txt
|
|
118
|
+
- README.rdoc
|
|
119
|
+
files:
|
|
120
|
+
- .document
|
|
121
|
+
- Gemfile
|
|
122
|
+
- Gemfile.lock
|
|
123
|
+
- LICENSE.txt
|
|
124
|
+
- README.rdoc
|
|
125
|
+
- Rakefile
|
|
126
|
+
- VERSION
|
|
127
|
+
- lib/magento-rb.rb
|
|
128
|
+
- lib/magento/savon.rb
|
|
129
|
+
- lib/magento/soap_api_v2.rb
|
|
130
|
+
- lib/magento/xml_api.rb
|
|
131
|
+
- magento-rb.gemspec
|
|
132
|
+
- test/helper.rb
|
|
133
|
+
- test/test_magento-rb.rb
|
|
134
|
+
has_rdoc: true
|
|
135
|
+
homepage: http://github.com/joelvh/magento-rb
|
|
136
|
+
licenses:
|
|
137
|
+
- MIT
|
|
138
|
+
post_install_message:
|
|
139
|
+
rdoc_options: []
|
|
140
|
+
|
|
141
|
+
require_paths:
|
|
142
|
+
- lib
|
|
143
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
144
|
+
none: false
|
|
145
|
+
requirements:
|
|
146
|
+
- - ">="
|
|
147
|
+
- !ruby/object:Gem::Version
|
|
148
|
+
hash: 3
|
|
149
|
+
segments:
|
|
150
|
+
- 0
|
|
151
|
+
version: "0"
|
|
152
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
153
|
+
none: false
|
|
154
|
+
requirements:
|
|
155
|
+
- - ">="
|
|
156
|
+
- !ruby/object:Gem::Version
|
|
157
|
+
hash: 3
|
|
158
|
+
segments:
|
|
159
|
+
- 0
|
|
160
|
+
version: "0"
|
|
161
|
+
requirements: []
|
|
162
|
+
|
|
163
|
+
rubyforge_project:
|
|
164
|
+
rubygems_version: 1.6.2
|
|
165
|
+
signing_key:
|
|
166
|
+
specification_version: 3
|
|
167
|
+
summary: Magento API libraries and other helpful Ruby code
|
|
168
|
+
test_files: []
|
|
169
|
+
|