honeys-place 0.0.1 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/honey/builder.rb +4 -4
- data/lib/honey/client.rb +8 -24
- data/lib/honey/error.rb +18 -18
- data/lib/honey/response.rb +6 -5
- data/lib/honey/version.rb +1 -1
- data/lib/nokogiri/xml/document_to_hash.rb +8 -1
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0a08af2d85e3a712366d811415666ffd8ea7a144
|
4
|
+
data.tar.gz: 8f38a52609bb94b604d9f0ee684c2e64df239b39
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 43f41616c775fd2115580cdab00a6fb3a13a4c61f74360fd096e3c5d3692bf959309f4cae3e7ccd3f92b4ae4f6a8d3066ef57709d3873f394f246a08d787e7d6
|
7
|
+
data.tar.gz: 193d2bdc502c26ec24054c058dd48f511762a889dc8c23093a1e2133c1e1564958ab4f5c3bcef17dbfc850004ac69829d7ca973f1d1490523b940b987c124d10
|
data/lib/honey/builder.rb
CHANGED
@@ -1,16 +1,16 @@
|
|
1
1
|
module Honey
|
2
2
|
class Builder
|
3
|
-
attr_reader :
|
3
|
+
attr_reader :account, :password
|
4
4
|
|
5
|
-
def initialize(
|
6
|
-
@
|
5
|
+
def initialize(account, password)
|
6
|
+
@account = account
|
7
7
|
@password = password
|
8
8
|
end
|
9
9
|
|
10
10
|
def build(data)
|
11
11
|
@data = Nokogiri::XML::Builder.new do |xml|
|
12
12
|
xml.HPEnvelope do
|
13
|
-
xml.
|
13
|
+
xml.account(account)
|
14
14
|
xml.password(password)
|
15
15
|
data.each_pair do |key, value|
|
16
16
|
xml_pair(xml, key, value)
|
data/lib/honey/client.rb
CHANGED
@@ -1,24 +1,10 @@
|
|
1
1
|
module Honey
|
2
2
|
class Client
|
3
3
|
include HTTParty
|
4
|
-
base_uri '
|
4
|
+
base_uri 'https://www.honeysplace.com/ws/'
|
5
5
|
|
6
|
-
def initialize(
|
7
|
-
login(
|
8
|
-
end
|
9
|
-
|
10
|
-
# type :xml, :text
|
11
|
-
def self.data_feed(type = :xml, path = '/tmp/honey')
|
12
|
-
IO.popen("curl #{self.class.base_uri}/#{data_feed_url(type)} -o #{path}.#{type}")
|
13
|
-
end
|
14
|
-
|
15
|
-
def self.data_feed_url(type = :xml)
|
16
|
-
"xml/honeysinventory" << case type
|
17
|
-
when :xml
|
18
|
-
"v2_0.xml"
|
19
|
-
when :txt
|
20
|
-
"_v_1.0.txt"
|
21
|
-
end
|
6
|
+
def initialize(account = '', token = '')
|
7
|
+
login(account, token)
|
22
8
|
end
|
23
9
|
|
24
10
|
def submit_order(order)
|
@@ -31,15 +17,13 @@ module Honey
|
|
31
17
|
|
32
18
|
def stock_check(*skus)
|
33
19
|
results = {}
|
34
|
-
if skus.first.is_a? Array
|
35
|
-
skus = skus.first
|
36
|
-
end
|
20
|
+
skus = skus.first if skus.first.is_a? Array
|
37
21
|
skus.each_slice(25) do |sku_group|
|
38
22
|
response = post(build_stock_check(*sku_group))
|
39
|
-
data = response.stock[
|
23
|
+
data = response.stock[:item]
|
40
24
|
data = [data] if sku_group.count == 1 # Honey's API Quirk
|
41
25
|
data.each do |datum|
|
42
|
-
results[datum[
|
26
|
+
results[datum[:sku]] = datum[:qty]
|
43
27
|
end
|
44
28
|
end
|
45
29
|
results
|
@@ -63,8 +47,8 @@ module Honey
|
|
63
47
|
Honey::Response.new(self.class.post('', { query: { xmldata: xml }}))
|
64
48
|
end
|
65
49
|
|
66
|
-
def login(
|
67
|
-
@builder = Honey::Builder.new(
|
50
|
+
def login(account, token)
|
51
|
+
@builder = Honey::Builder.new(account, token)
|
68
52
|
end
|
69
53
|
|
70
54
|
def request(object)
|
data/lib/honey/error.rb
CHANGED
@@ -11,25 +11,25 @@ module Honey
|
|
11
11
|
|
12
12
|
CODES = {
|
13
13
|
999 => "An invalid username / password has been submitted. Please contact Honey's Place.",
|
14
|
-
800 =>
|
15
|
-
801 =>
|
16
|
-
802 =>
|
17
|
-
803 =>
|
18
|
-
804 =>
|
19
|
-
805 =>
|
20
|
-
806 =>
|
21
|
-
807 =>
|
22
|
-
808 =>
|
23
|
-
809 =>
|
24
|
-
700 =>
|
25
|
-
701 =>
|
26
|
-
600 =>
|
27
|
-
500 =>
|
28
|
-
501 =>
|
14
|
+
800 => 'First Name is required.',
|
15
|
+
801 => 'Last Name is required.',
|
16
|
+
802 => 'Address1 is required.',
|
17
|
+
803 => 'City is required.',
|
18
|
+
804 => 'State is required.',
|
19
|
+
805 => 'Zip Code is required.',
|
20
|
+
806 => 'Zip Code is invalid.',
|
21
|
+
807 => 'Country is invalid.',
|
22
|
+
808 => 'E-Mail is invalid.',
|
23
|
+
809 => 'State must be only 2 characters.',
|
24
|
+
700 => 'Reference number already used.',
|
25
|
+
701 => 'Reference number is required.',
|
26
|
+
600 => 'Invalid Shipping Code.',
|
27
|
+
500 => 'One or more of the submitted products have been discontinued by the manufacturer.',
|
28
|
+
501 => 'One or more of the submitted products do not exist.',
|
29
29
|
400 => "Duplicate product within same order. Please combine SKU's and QTY.",
|
30
|
-
300 =>
|
31
|
-
100 =>
|
30
|
+
300 => 'You are checking status on an order you have not yet submitted.',
|
31
|
+
100 => 'Order accepted for processing.',
|
32
32
|
0 => "Unknown Error. Please contact Honey's Place."
|
33
|
-
}
|
33
|
+
}.freeze
|
34
34
|
end
|
35
35
|
end
|
data/lib/honey/response.rb
CHANGED
@@ -5,14 +5,15 @@ module Honey
|
|
5
5
|
attr_accessor :data
|
6
6
|
|
7
7
|
def initialize(http_response)
|
8
|
-
|
8
|
+
doc = Nokogiri::XML(http_response.parsed_response)
|
9
|
+
@data = OpenStruct.new(doc.to_hash[:HPEnvelope])
|
9
10
|
end
|
10
11
|
|
11
12
|
def method_missing(method, *args, &block)
|
12
13
|
if method.to_s.end_with?('=')
|
13
|
-
data.
|
14
|
+
data.send(method, *args)
|
14
15
|
else
|
15
|
-
data.
|
16
|
+
data.send(method)
|
16
17
|
end
|
17
18
|
end
|
18
19
|
|
@@ -29,11 +30,11 @@ module Honey
|
|
29
30
|
end
|
30
31
|
|
31
32
|
def cancelled?
|
32
|
-
data.cancelled ==
|
33
|
+
data.cancelled == 'Yes'
|
33
34
|
end
|
34
35
|
|
35
36
|
def shipped?
|
36
|
-
data.status ==
|
37
|
+
data.status == 'Shipped'
|
37
38
|
end
|
38
39
|
|
39
40
|
def error
|
data/lib/honey/version.rb
CHANGED
@@ -10,7 +10,14 @@ module Nokogiri
|
|
10
10
|
hash = {}
|
11
11
|
children.each do |child|
|
12
12
|
if child.children.any?
|
13
|
-
hash
|
13
|
+
if hash.key?(child.name.to_sym)
|
14
|
+
hash[child.name.to_sym] = [
|
15
|
+
hash[child.name.to_sym],
|
16
|
+
children_to_hash(child.children)
|
17
|
+
]
|
18
|
+
else
|
19
|
+
hash[child.name.to_sym] = children_to_hash(child.children)
|
20
|
+
end
|
14
21
|
else
|
15
22
|
hash = child.content.to_s
|
16
23
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: honeys-place
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jacob Evan Shreve
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-11-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|
@@ -106,14 +106,14 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
106
106
|
version: '0'
|
107
107
|
requirements: []
|
108
108
|
rubyforge_project:
|
109
|
-
rubygems_version: 2.
|
109
|
+
rubygems_version: 2.6.11
|
110
110
|
signing_key:
|
111
111
|
specification_version: 4
|
112
112
|
summary: A wrapper for the Honey's Place API
|
113
113
|
test_files:
|
114
|
+
- test/honey_test.rb
|
115
|
+
- test/test_helper.rb
|
116
|
+
- test/nokogiri/xml/document_to_hash_test.rb
|
114
117
|
- test/honey/builder_test.rb
|
115
118
|
- test/honey/client_test.rb
|
116
119
|
- test/honey/order_test.rb
|
117
|
-
- test/honey_test.rb
|
118
|
-
- test/nokogiri/xml/document_to_hash_test.rb
|
119
|
-
- test/test_helper.rb
|