atlast 0.0.1

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/.gitignore ADDED
@@ -0,0 +1,4 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in atlast.gemspec
4
+ gemspec
data/README.md ADDED
@@ -0,0 +1,4 @@
1
+ AtLast API Integrator
2
+ =====
3
+
4
+ This is in a very rough state, but is designed to integrate with the AtLast Fulfillment API.
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
data/atlast.gemspec ADDED
@@ -0,0 +1,27 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "atlast/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "atlast"
7
+ s.version = Atlast::VERSION
8
+ s.authors = ["Gerred Dillon"]
9
+ s.email = ["hello@gerred.com"]
10
+ s.homepage = ""
11
+ s.summary = %q{This integrates with the AtLast API}
12
+ s.description = %q{Very rough state, but integrates with the AtLast API}
13
+
14
+ s.rubyforge_project = "atlast"
15
+
16
+ s.files = `git ls-files`.split("\n")
17
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
18
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
19
+ s.require_paths = ["lib"]
20
+
21
+ # specify any dependencies here; for example:
22
+ # s.add_development_dependency "rspec"
23
+ s.add_runtime_dependency "rest-client"
24
+ s.add_runtime_dependency "builder"
25
+ s.add_runtime_dependency "crack"
26
+ s.add_runtime_dependency "uuid"
27
+ end
data/lib/atlast.rb ADDED
@@ -0,0 +1,9 @@
1
+ require 'builder'
2
+ require 'rest-client'
3
+ require 'crack'
4
+ require "atlast/version"
5
+ require 'uuid'
6
+ require 'atlast/fulfillment'
7
+
8
+ module Atlast
9
+ end
@@ -0,0 +1,73 @@
1
+ module Atlast
2
+ class Fulfillment
3
+ ROOT_URL = "https://api.atlastfulfillment.com"
4
+ attr_accessor :key
5
+
6
+ def initialize(key)
7
+ @key = key
8
+ end
9
+
10
+ def products
11
+ products_xml = RestClient.get(ROOT_URL + "/products.aspx", params: {key: key})
12
+ Crack::XML.parse products_xml
13
+ end
14
+
15
+ def product(sku)
16
+ end
17
+
18
+ def inventory(sku=nil)
19
+ params = {key: key}
20
+ params[:sku] = sku if sku
21
+
22
+ inventory_xml = RestClient.get ROOT_URL + "/inventory.aspx", params: params
23
+ Crack::XML.parse inventory_xml
24
+ end
25
+
26
+ def available?(sku)
27
+ inventory(sku)["response"]["products"]["product"]["availableQuantity"].to_i > 0
28
+ end
29
+
30
+ def ship(options)
31
+ address = options[:address]
32
+ ship_method = options[:ship_method]
33
+ items = options[:items]
34
+ order_id = options[:order_id] || UUID.new.generate
35
+
36
+ builder = Builder::XmlMarkup.new
37
+ builder.instruct! :xml, version: "1.0", encoding: "UTF-8"
38
+ xml = builder.Orders(apiKey: key) do |orders|
39
+ orders.Order(orderID: order_id) do |order|
40
+ order.CustomerInfo do |ci|
41
+ ci.FirstName address.first_name
42
+ ci.LastName address.last_name
43
+ ci.Address1 address.address
44
+ ci.Address2 address.suite
45
+ ci.City address.city
46
+ ci.State address.state
47
+ ci.Zip address.postal_code
48
+ ci.Country "USA"
49
+ end
50
+ order.OrderDate Time.now.strftime("%D")
51
+ order.ShipMethod ship_method
52
+ order.Items do |xml_items|
53
+ items.each do |item|
54
+ xml_items.Item do |xml_item|
55
+ xml_item.SKU item.sku
56
+ xml_item.Qty item.quantity
57
+ end
58
+ end
59
+ end
60
+ end
61
+ end
62
+ response = RestClient.post(ROOT_URL + "/post_shipments.aspx", xml, content_type: :xml, accept: :xml)
63
+ Crack::XML.parse response
64
+ end
65
+
66
+ def cancel(order_id)
67
+ params = {key: key, orderId: order_id}
68
+ response = RestClient.get ROOT_URL + "/cancel_shipment.aspx", params: params
69
+ Crack::XML.parse response
70
+ end
71
+ end
72
+
73
+ end
@@ -0,0 +1,3 @@
1
+ module Atlast
2
+ VERSION = "0.0.1"
3
+ end
metadata ADDED
@@ -0,0 +1,97 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: atlast
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Gerred Dillon
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2011-12-01 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rest-client
16
+ requirement: &70141212988240 !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: *70141212988240
25
+ - !ruby/object:Gem::Dependency
26
+ name: builder
27
+ requirement: &70141212987820 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: *70141212987820
36
+ - !ruby/object:Gem::Dependency
37
+ name: crack
38
+ requirement: &70141212987400 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
44
+ type: :runtime
45
+ prerelease: false
46
+ version_requirements: *70141212987400
47
+ - !ruby/object:Gem::Dependency
48
+ name: uuid
49
+ requirement: &70141212986980 !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ type: :runtime
56
+ prerelease: false
57
+ version_requirements: *70141212986980
58
+ description: Very rough state, but integrates with the AtLast API
59
+ email:
60
+ - hello@gerred.com
61
+ executables: []
62
+ extensions: []
63
+ extra_rdoc_files: []
64
+ files:
65
+ - .gitignore
66
+ - Gemfile
67
+ - README.md
68
+ - Rakefile
69
+ - atlast.gemspec
70
+ - lib/atlast.rb
71
+ - lib/atlast/fulfillment.rb
72
+ - lib/atlast/version.rb
73
+ homepage: ''
74
+ licenses: []
75
+ post_install_message:
76
+ rdoc_options: []
77
+ require_paths:
78
+ - lib
79
+ required_ruby_version: !ruby/object:Gem::Requirement
80
+ none: false
81
+ requirements:
82
+ - - ! '>='
83
+ - !ruby/object:Gem::Version
84
+ version: '0'
85
+ required_rubygems_version: !ruby/object:Gem::Requirement
86
+ none: false
87
+ requirements:
88
+ - - ! '>='
89
+ - !ruby/object:Gem::Version
90
+ version: '0'
91
+ requirements: []
92
+ rubyforge_project: atlast
93
+ rubygems_version: 1.8.11
94
+ signing_key:
95
+ specification_version: 3
96
+ summary: This integrates with the AtLast API
97
+ test_files: []