americommerce-api 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +2 -0
- data/americommerce-api.gemspec +16 -0
- data/lib/americommerce-api.rb +10 -0
- data/lib/americommerce/api.rb +75 -0
- data/lib/americommerce/configuration.rb +15 -0
- data/lib/americommerce/exceptions.rb +5 -0
- data/lib/americommerce/response.rb +9 -0
- data/lib/americommerce/version.rb +3 -0
- metadata +68 -0
data/README.md
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
$:.push File.expand_path("../lib", __FILE__)
|
2
|
+
require "americommerce/version"
|
3
|
+
Gem::Specification.new do |s|
|
4
|
+
s.name = "americommerce-api"
|
5
|
+
s.version = Americommerce::VERSION
|
6
|
+
s.date = Time.now.strftime("%Y-%m-%d")
|
7
|
+
s.summary = "Enables Ruby applications to communicate with the Americommerce API"
|
8
|
+
s.email = "omri@yotpo.com"
|
9
|
+
s.homepage = "https://github.com/YotpoLtd/americommerce-api"
|
10
|
+
s.description = "Enables Ruby applications to communicate with the Ebay Trading API."
|
11
|
+
s.has_rdoc = false
|
12
|
+
s.require_paths = ['lib']
|
13
|
+
s.authors = ["Yotpo/avichay@yotpo"]
|
14
|
+
s.files = ["README.md", "americommerce-api.gemspec"] + Dir['**/*.rb'] + Dir['**/*.crt']
|
15
|
+
s.add_dependency 'savon'
|
16
|
+
end
|
@@ -0,0 +1,75 @@
|
|
1
|
+
module AmericommerceApi
|
2
|
+
class Api
|
3
|
+
|
4
|
+
AUTHENTICATE_WSDL = File.read(File.expand_path('../wsdl/americommercedb.asmx.wsdl', __FILE__))
|
5
|
+
WSDL_POSTFIX = '/store/ws/AmeriCommerceDb.asmx?wsdl'
|
6
|
+
|
7
|
+
NAMESPACES = {
|
8
|
+
'xmlns' => 'http://www.americommerce.com'
|
9
|
+
}
|
10
|
+
|
11
|
+
|
12
|
+
def initialize(options)
|
13
|
+
|
14
|
+
@ac_header = {
|
15
|
+
'AmeriCommerceHeaderInfo' => {
|
16
|
+
'UserName' => options[:username],
|
17
|
+
'Password' => options[:password],
|
18
|
+
'SecurityToken' => options[:token]
|
19
|
+
}
|
20
|
+
}
|
21
|
+
|
22
|
+
@store_domain = options[:store_domain] + WSDL_POSTFIX
|
23
|
+
|
24
|
+
@client = AmericommerceApi::Api.init_client(@ac_header, @store_domain)
|
25
|
+
end
|
26
|
+
|
27
|
+
def get_orders(options = {})
|
28
|
+
start_date = options[:start_date] || DateTime.new
|
29
|
+
end_date = options[:end_date] || DateTime.now
|
30
|
+
request(:order_get_by_edit_date_range_pre_filled, {'pdtStartDateTime' => start_date.to_datetime, 'pdtEndDateTime' => end_date.to_datetime})
|
31
|
+
end
|
32
|
+
|
33
|
+
def get_product_by_id(product_id)
|
34
|
+
request(:product_get_by_key, {'piitemID' => product_id})
|
35
|
+
end
|
36
|
+
|
37
|
+
def get_product_url(product_id)
|
38
|
+
request(:product_get_current_url, {'piProductID' => product_id})
|
39
|
+
end
|
40
|
+
|
41
|
+
def get_all_order_statuses
|
42
|
+
request(:order_status_get_all)
|
43
|
+
end
|
44
|
+
|
45
|
+
def ping
|
46
|
+
begin
|
47
|
+
wsdl = AUTHENTICATE_WSDL % {store_domain: @store_domain}
|
48
|
+
@client = AmericommerceApi::Api.init_client(@ac_header,wsdl)
|
49
|
+
response = request(:authenticate)
|
50
|
+
raise AmericommerceApi::Exceptions::InvalidCredentials unless response == true
|
51
|
+
rescue
|
52
|
+
raise AmericommerceApi::Exceptions::InvalidCredentials
|
53
|
+
ensure
|
54
|
+
@client = AmericommerceApi::Api.init_client(@ac_header, @store_domain)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
private
|
59
|
+
|
60
|
+
def request(call_action, request_params={})
|
61
|
+
response = @client.call(call_action, message: request_params)
|
62
|
+
return AmericommerceApi::Response.format(response, call_action)
|
63
|
+
end
|
64
|
+
|
65
|
+
def self.init_client(ac_header, wsdl)
|
66
|
+
return Savon.client({
|
67
|
+
:ssl_verify_mode => :none,
|
68
|
+
:wsdl => wsdl,
|
69
|
+
:soap_header => ac_header,
|
70
|
+
:namespaces => NAMESPACES
|
71
|
+
})
|
72
|
+
end
|
73
|
+
|
74
|
+
end
|
75
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module AmericommerceApi
|
2
|
+
# Configures Plugin.
|
3
|
+
def self.configure(configuration = AmericommerceApi::Configuration.new)
|
4
|
+
yield configuration if block_given?
|
5
|
+
@@configuration = configuration
|
6
|
+
end
|
7
|
+
|
8
|
+
def self.configuration
|
9
|
+
@@configuration ||= AmericommerceApi::Configuration.new
|
10
|
+
end
|
11
|
+
|
12
|
+
class Configuration
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
module AmericommerceApi
|
2
|
+
class Response
|
3
|
+
def self.format(response, call_action)
|
4
|
+
call_action = call_action.to_s
|
5
|
+
response = response.body ? response.body["#{call_action}_response".to_sym] : nil
|
6
|
+
return response ? response["#{call_action}_result".to_sym] : nil
|
7
|
+
end
|
8
|
+
end
|
9
|
+
end
|
metadata
ADDED
@@ -0,0 +1,68 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: americommerce-api
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Yotpo/avichay@yotpo
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-11-07 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: savon
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
description: Enables Ruby applications to communicate with the Ebay Trading API.
|
31
|
+
email: omri@yotpo.com
|
32
|
+
executables: []
|
33
|
+
extensions: []
|
34
|
+
extra_rdoc_files: []
|
35
|
+
files:
|
36
|
+
- README.md
|
37
|
+
- americommerce-api.gemspec
|
38
|
+
- lib/americommerce/api.rb
|
39
|
+
- lib/americommerce/configuration.rb
|
40
|
+
- lib/americommerce/exceptions.rb
|
41
|
+
- lib/americommerce/response.rb
|
42
|
+
- lib/americommerce/version.rb
|
43
|
+
- lib/americommerce-api.rb
|
44
|
+
homepage: https://github.com/YotpoLtd/americommerce-api
|
45
|
+
licenses: []
|
46
|
+
post_install_message:
|
47
|
+
rdoc_options: []
|
48
|
+
require_paths:
|
49
|
+
- lib
|
50
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
51
|
+
none: false
|
52
|
+
requirements:
|
53
|
+
- - ! '>='
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '0'
|
56
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
requirements: []
|
63
|
+
rubyforge_project:
|
64
|
+
rubygems_version: 1.8.24
|
65
|
+
signing_key:
|
66
|
+
specification_version: 3
|
67
|
+
summary: Enables Ruby applications to communicate with the Americommerce API
|
68
|
+
test_files: []
|