magentor 0.1.0
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/MIT-LICENSE +19 -0
- data/README.rdoc +45 -0
- data/Rakefile +16 -0
- data/TODOS +3 -0
- data/VERSION +1 -0
- data/init.rb +1 -0
- data/lib/magento/base.rb +55 -0
- data/lib/magento/category.rb +215 -0
- data/lib/magento/category_attribute.rb +42 -0
- data/lib/magento/connection.rb +23 -0
- data/lib/magento/country.rb +21 -0
- data/lib/magento/customer.rb +122 -0
- data/lib/magento/customer_address.rb +101 -0
- data/lib/magento/customer_group.rb +17 -0
- data/lib/magento/inventory.rb +4 -0
- data/lib/magento/invoice.rb +132 -0
- data/lib/magento/order.rb +103 -0
- data/lib/magento/product.rb +159 -0
- data/lib/magento/product_attribute.rb +49 -0
- data/lib/magento/product_attribute_set.rb +17 -0
- data/lib/magento/product_link.rb +90 -0
- data/lib/magento/product_media.rb +122 -0
- data/lib/magento/product_stock.rb +36 -0
- data/lib/magento/product_tier_price.rb +51 -0
- data/lib/magento/product_type.rb +17 -0
- data/lib/magento/region.rb +25 -0
- data/lib/magento/shipment.rb +127 -0
- data/lib/magento.rb +16 -0
- metadata +97 -0
@@ -0,0 +1,51 @@
|
|
1
|
+
module Magento
|
2
|
+
# http://www.magentocommerce.com/wiki/doc/webservices-api/api/catalog_product_type
|
3
|
+
# 100 Product not exists.
|
4
|
+
# 101 Invalid data given. Details in error message.
|
5
|
+
# 102 Tier prices not updated. Details in error message.
|
6
|
+
class ProductTierPrice < Base
|
7
|
+
class << self
|
8
|
+
# catalog_product_attribute_tier_price.info
|
9
|
+
# Retrieve product tier prices
|
10
|
+
#
|
11
|
+
# Return: array - array of tier prices array(array(’website’ ⇒ ..., ‘customer_group_id’ ⇒ ..., ‘qty’ ⇒ ..., ‘price’ ⇒ ...))
|
12
|
+
#
|
13
|
+
# Arguments:
|
14
|
+
#
|
15
|
+
# mixed product - product ID or Sku
|
16
|
+
def info(*args)
|
17
|
+
new(commit("info", *args))
|
18
|
+
end
|
19
|
+
|
20
|
+
# catalog_product_attribute_tier_price.update
|
21
|
+
# Update product tier prices
|
22
|
+
#
|
23
|
+
# Return: boolean
|
24
|
+
#
|
25
|
+
# Arguments:
|
26
|
+
#
|
27
|
+
# mixed product - product ID or Sku
|
28
|
+
# array tierPrices - array of tier prices
|
29
|
+
# => array(array(’website’ ⇒ ..., ‘customer_group_id’ ⇒ ..., ‘qty’ ⇒ ..., ‘price’ ⇒ ...))
|
30
|
+
def update(*args)
|
31
|
+
commit("update", *args)
|
32
|
+
end
|
33
|
+
|
34
|
+
def find_by_product_id_or_sku(id)
|
35
|
+
list(id)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
# def update_attribute(name, value)
|
40
|
+
# # TODO: find actual name of field for product id or sku
|
41
|
+
# @attributes[name] = value
|
42
|
+
# self.class.update(self.product, Hash[*[name.to_sym, value]])
|
43
|
+
# end
|
44
|
+
#
|
45
|
+
# def update_attributes(attrs)
|
46
|
+
# # TODO: find actual name of field for product id or sku
|
47
|
+
# attrs.each_pair { |k, v| @attributes[k] = v }
|
48
|
+
# self.class.update(self.product, attrs)
|
49
|
+
# end
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Magento
|
2
|
+
# http://www.magentocommerce.com/wiki/doc/webservices-api/api/catalog_product_type
|
3
|
+
class ProductType < Base
|
4
|
+
class << self
|
5
|
+
# catalog_product_type.list
|
6
|
+
# Retrieve product types
|
7
|
+
#
|
8
|
+
# Return: array
|
9
|
+
def list
|
10
|
+
results = commit("list", nil)
|
11
|
+
results.collect do |result|
|
12
|
+
new(result)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module Magento
|
2
|
+
# http://www.magentocommerce.com/wiki/doc/webservices-api/api/directory_region
|
3
|
+
class Region < Base
|
4
|
+
class << self
|
5
|
+
# directory_region.list
|
6
|
+
# List of regions in specified country
|
7
|
+
#
|
8
|
+
# Return: array
|
9
|
+
#
|
10
|
+
# Arguments:
|
11
|
+
#
|
12
|
+
# string $country - Country code in ISO2 or ISO3
|
13
|
+
def list(*args)
|
14
|
+
results = commit("list", *args)
|
15
|
+
results.collect do |result|
|
16
|
+
new(result)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def find_by_country(iso)
|
21
|
+
list(iso)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,127 @@
|
|
1
|
+
module Magento
|
2
|
+
# http://www.magentocommerce.com/wiki/doc/webservices-api/api/sales_order_shipment
|
3
|
+
# 100 Requested shipment not exists.
|
4
|
+
# 101 Invalid filters given. Details in error message.
|
5
|
+
# 102 Invalid data given. Details in error message.
|
6
|
+
# 103 Requested order not exists.
|
7
|
+
# 104 Requested tracking not exists.
|
8
|
+
# 105 Tracking not deleted. Details in error message.
|
9
|
+
class Shipment < Base
|
10
|
+
class << self
|
11
|
+
# sales_order_shipment.list
|
12
|
+
# Retrieve list of shipments by filters
|
13
|
+
#
|
14
|
+
# Return: array
|
15
|
+
#
|
16
|
+
# Arguments:
|
17
|
+
#
|
18
|
+
# array filters - filters for shipments list
|
19
|
+
def list(*args)
|
20
|
+
results = commit("list", *args)
|
21
|
+
results.collect do |result|
|
22
|
+
new(result)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
# sales_order_shipment.info
|
27
|
+
# Retrieve shipment information
|
28
|
+
#
|
29
|
+
# Return: array
|
30
|
+
#
|
31
|
+
# Arguments:
|
32
|
+
#
|
33
|
+
# string shipmentIncrementId - order shipment increment id
|
34
|
+
def info(*args)
|
35
|
+
new(commit("info", *args))
|
36
|
+
end
|
37
|
+
|
38
|
+
# sales_order_shipment.create
|
39
|
+
# Create new shipment for order
|
40
|
+
#
|
41
|
+
# Return: string - shipment increment id
|
42
|
+
#
|
43
|
+
# Arguments:
|
44
|
+
#
|
45
|
+
# string orderIncrementId - order increment id
|
46
|
+
# array itemsQty - items qty to ship as associative array (order_item_id ⇒ qty)
|
47
|
+
# string comment - shipment comment (optional)
|
48
|
+
# boolean email - send e-mail flag (optional)
|
49
|
+
# boolean includeComment - include comment in e-mail flag (optional)
|
50
|
+
def create(*args)
|
51
|
+
id = commit("create", *args)
|
52
|
+
record = info(id)
|
53
|
+
record
|
54
|
+
end
|
55
|
+
|
56
|
+
# sales_order_shipment.addComment
|
57
|
+
# Add new comment to shipment
|
58
|
+
#
|
59
|
+
# Return: boolean
|
60
|
+
#
|
61
|
+
# Arguments:
|
62
|
+
#
|
63
|
+
# string shipmentIncrementId - shipment increment id
|
64
|
+
# string comment - shipment comment
|
65
|
+
# boolean email - send e-mail flag (optional)
|
66
|
+
# boolean includeInEmail - include comment in e-mail flag (optional)
|
67
|
+
def add_comment(*args)
|
68
|
+
commit('addComment', *args)
|
69
|
+
end
|
70
|
+
|
71
|
+
# sales_order_shipment.addTrack
|
72
|
+
# Add new tracking number
|
73
|
+
#
|
74
|
+
# Return: int
|
75
|
+
#
|
76
|
+
# Arguments:
|
77
|
+
#
|
78
|
+
# string shipmentIncrementId - shipment increment id
|
79
|
+
# string carrier - carrier code
|
80
|
+
# string title - tracking title
|
81
|
+
# string trackNumber - tracking number
|
82
|
+
def add_track(*args)
|
83
|
+
commit('addTrack', *args)
|
84
|
+
end
|
85
|
+
|
86
|
+
# sales_order_shipment.removeTrack
|
87
|
+
# Remove tracking number
|
88
|
+
#
|
89
|
+
# Return: boolean
|
90
|
+
#
|
91
|
+
# Arguments:
|
92
|
+
#
|
93
|
+
# string shipmentIncrementId - shipment increment id
|
94
|
+
# int trackId - track id
|
95
|
+
def remove_track(*args)
|
96
|
+
commit('removeTrack', *args)
|
97
|
+
end
|
98
|
+
|
99
|
+
# sales_order_shipment.getCarriers
|
100
|
+
# Retrieve list of allowed carriers for order
|
101
|
+
#
|
102
|
+
# Return: array
|
103
|
+
#
|
104
|
+
# Arguments:
|
105
|
+
#
|
106
|
+
# string orderIncrementId - order increment id
|
107
|
+
def get_carriers(*args)
|
108
|
+
commit('getCarriers', *args)
|
109
|
+
end
|
110
|
+
|
111
|
+
def find_by_id(id)
|
112
|
+
info(id)
|
113
|
+
end
|
114
|
+
|
115
|
+
def find(find_type, options = {})
|
116
|
+
filters = {}
|
117
|
+
options.each_pair { |k, v| filters[k] = {:eq => v} }
|
118
|
+
results = list(filters)
|
119
|
+
if find_type == :first
|
120
|
+
results.first
|
121
|
+
else
|
122
|
+
results
|
123
|
+
end
|
124
|
+
end
|
125
|
+
end
|
126
|
+
end
|
127
|
+
end
|
data/lib/magento.rb
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
# Ruby wrapper for the magento api
|
2
|
+
#
|
3
|
+
# Author:: Preston Stuteville (mailto:preston.stuteville@gmail.com)
|
4
|
+
# License:: MIT
|
5
|
+
#
|
6
|
+
# Inspiration from the Magento plugin from Tim Matheson (http://github.com/timmatheson/Magento)
|
7
|
+
|
8
|
+
require 'magento/connection'
|
9
|
+
|
10
|
+
#require 'xmlrpc'
|
11
|
+
require 'xmlrpc/client'
|
12
|
+
|
13
|
+
require 'magento/base'
|
14
|
+
|
15
|
+
XMLRPC::Config::ENABLE_NIL_PARSER = true
|
16
|
+
XMLRPC::Config::ENABLE_NIL_CREATE = true
|
metadata
ADDED
@@ -0,0 +1,97 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: magentor
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 27
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 1
|
9
|
+
- 0
|
10
|
+
version: 0.1.0
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Preston Stuteville
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2010-09-24 00:00:00 -07:00
|
19
|
+
default_executable:
|
20
|
+
dependencies: []
|
21
|
+
|
22
|
+
description:
|
23
|
+
email: preston.stuteville@gmail.com
|
24
|
+
executables: []
|
25
|
+
|
26
|
+
extensions: []
|
27
|
+
|
28
|
+
extra_rdoc_files:
|
29
|
+
- README.rdoc
|
30
|
+
files:
|
31
|
+
- MIT-LICENSE
|
32
|
+
- README.rdoc
|
33
|
+
- Rakefile
|
34
|
+
- TODOS
|
35
|
+
- VERSION
|
36
|
+
- init.rb
|
37
|
+
- lib/magento.rb
|
38
|
+
- lib/magento/base.rb
|
39
|
+
- lib/magento/category.rb
|
40
|
+
- lib/magento/category_attribute.rb
|
41
|
+
- lib/magento/connection.rb
|
42
|
+
- lib/magento/country.rb
|
43
|
+
- lib/magento/customer.rb
|
44
|
+
- lib/magento/customer_address.rb
|
45
|
+
- lib/magento/customer_group.rb
|
46
|
+
- lib/magento/inventory.rb
|
47
|
+
- lib/magento/invoice.rb
|
48
|
+
- lib/magento/order.rb
|
49
|
+
- lib/magento/product.rb
|
50
|
+
- lib/magento/product_attribute.rb
|
51
|
+
- lib/magento/product_attribute_set.rb
|
52
|
+
- lib/magento/product_link.rb
|
53
|
+
- lib/magento/product_media.rb
|
54
|
+
- lib/magento/product_stock.rb
|
55
|
+
- lib/magento/product_tier_price.rb
|
56
|
+
- lib/magento/product_type.rb
|
57
|
+
- lib/magento/region.rb
|
58
|
+
- lib/magento/shipment.rb
|
59
|
+
has_rdoc: true
|
60
|
+
homepage: http://github.com/pstuteville/magentor
|
61
|
+
licenses: []
|
62
|
+
|
63
|
+
post_install_message:
|
64
|
+
rdoc_options:
|
65
|
+
- --main
|
66
|
+
- README.rdoc
|
67
|
+
- --inline-source
|
68
|
+
- --line-numbers
|
69
|
+
require_paths:
|
70
|
+
- lib
|
71
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
72
|
+
none: false
|
73
|
+
requirements:
|
74
|
+
- - ">="
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
hash: 3
|
77
|
+
segments:
|
78
|
+
- 0
|
79
|
+
version: "0"
|
80
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ">="
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
hash: 3
|
86
|
+
segments:
|
87
|
+
- 0
|
88
|
+
version: "0"
|
89
|
+
requirements: []
|
90
|
+
|
91
|
+
rubyforge_project:
|
92
|
+
rubygems_version: 1.3.7
|
93
|
+
signing_key:
|
94
|
+
specification_version: 3
|
95
|
+
summary: Ruby wrapper for the Magento xmlrpc api
|
96
|
+
test_files: []
|
97
|
+
|