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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4c8bcca4987d91d3dade107ade3eff462b8d999e
4
- data.tar.gz: 2f33b11637765359f8879336be2115cd000fcaa4
3
+ metadata.gz: 0a08af2d85e3a712366d811415666ffd8ea7a144
4
+ data.tar.gz: 8f38a52609bb94b604d9f0ee684c2e64df239b39
5
5
  SHA512:
6
- metadata.gz: b59f1069e1952f9c79c79f0e4d8ba6db4cfde0e9670c25b4bee5b56561211d0279436d50b8b13e77ca03f317bded74dd16e7975b49cdf6755351f3d0484292ea
7
- data.tar.gz: d4d5e02b8b92a742ff9b31e9a3f87a11ba0a357d7e729d7921f56b319121cae2a44376b7977e07d5e2e391c0c868fb1f4af393cfd228b91c7bf73a5942d21bac
6
+ metadata.gz: 43f41616c775fd2115580cdab00a6fb3a13a4c61f74360fd096e3c5d3692bf959309f4cae3e7ccd3f92b4ae4f6a8d3066ef57709d3873f394f246a08d787e7d6
7
+ data.tar.gz: 193d2bdc502c26ec24054c058dd48f511762a889dc8c23093a1e2133c1e1564958ab4f5c3bcef17dbfc850004ac69829d7ca973f1d1490523b940b987c124d10
@@ -1,16 +1,16 @@
1
1
  module Honey
2
2
  class Builder
3
- attr_reader :username, :password
3
+ attr_reader :account, :password
4
4
 
5
- def initialize(username, password)
6
- @username = username
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.username(username)
13
+ xml.account(account)
14
14
  xml.password(password)
15
15
  data.each_pair do |key, value|
16
16
  xml_pair(xml, key, value)
@@ -1,24 +1,10 @@
1
1
  module Honey
2
2
  class Client
3
3
  include HTTParty
4
- base_uri 'http://ws.honeysplace.com/ws/'
4
+ base_uri 'https://www.honeysplace.com/ws/'
5
5
 
6
- def initialize(username = '', password = '')
7
- login(username, password)
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["item"]
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["sku"]] = datum["qty"]
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(username, password)
67
- @builder = Honey::Builder.new(username, password)
50
+ def login(account, token)
51
+ @builder = Honey::Builder.new(account, token)
68
52
  end
69
53
 
70
54
  def request(object)
@@ -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 => "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.",
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 => "You are checking status on an order you have not yet submitted.",
31
- 100 => "Order accepted for processing.",
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
@@ -5,14 +5,15 @@ module Honey
5
5
  attr_accessor :data
6
6
 
7
7
  def initialize(http_response)
8
- @data = OpenStruct.new(http_response.parsed_response["message"])
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.try(method, *args)
14
+ data.send(method, *args)
14
15
  else
15
- data.try(method)
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 == "Yes"
33
+ data.cancelled == 'Yes'
33
34
  end
34
35
 
35
36
  def shipped?
36
- data.status == "Shipped"
37
+ data.status == 'Shipped'
37
38
  end
38
39
 
39
40
  def error
@@ -1,3 +1,3 @@
1
1
  module Honey
2
- Version = "0.0.1"
2
+ Version = '0.1.0'.freeze
3
3
  end
@@ -10,7 +10,14 @@ module Nokogiri
10
10
  hash = {}
11
11
  children.each do |child|
12
12
  if child.children.any?
13
- hash[child.name.to_sym] = children_to_hash(child.children)
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.1
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: 2016-05-15 00:00:00.000000000 Z
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.4.5
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