blastramp 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,4 @@
1
+ pkg/*
2
+ *.gem
3
+ .bundle
4
+ spec/*.log
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in blastramp.gemspec
4
+ gemspec
@@ -0,0 +1,46 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ blastramp (0.0.1)
5
+
6
+ GEM
7
+ remote: http://rubygems.org/
8
+ specs:
9
+ builder (3.0.0)
10
+ crack (0.1.8)
11
+ diff-lcs (1.1.2)
12
+ gyoku (0.4.4)
13
+ builder (>= 2.1.2)
14
+ httpi (0.9.4)
15
+ pyu-ntlm-http (>= 0.1.3.1)
16
+ rack
17
+ mocha (0.9.12)
18
+ pyu-ntlm-http (0.1.3.1)
19
+ rack (1.3.0)
20
+ rspec (2.3.0)
21
+ rspec-core (~> 2.3.0)
22
+ rspec-expectations (~> 2.3.0)
23
+ rspec-mocks (~> 2.3.0)
24
+ rspec-core (2.3.1)
25
+ rspec-expectations (2.3.0)
26
+ diff-lcs (~> 1.1.2)
27
+ rspec-mocks (2.3.0)
28
+ savon (0.8.6)
29
+ builder (>= 2.1.2)
30
+ crack (~> 0.1.8)
31
+ gyoku (>= 0.3.0)
32
+ httpi (>= 0.7.8)
33
+ savon_spec (0.1.6)
34
+ mocha (>= 0.9.8)
35
+ rspec (>= 2.0.0)
36
+ savon (>= 0.8.0)
37
+
38
+ PLATFORMS
39
+ ruby
40
+
41
+ DEPENDENCIES
42
+ blastramp!
43
+ mocha (~> 0.9.8)
44
+ rspec (~> 2.3.0)
45
+ savon (~> 0.8.0.beta.3)
46
+ savon_spec (~> 0.1.6)
data/LICENSE ADDED
@@ -0,0 +1,19 @@
1
+ Copyright (C) 2011 by Zkron Technologies (zkron.com)
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to deal
5
+ in the Software without restriction, including without limitation the rights
6
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ copies of the Software, and to permit persons to whom the Software is
8
+ furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in
11
+ all copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+ THE SOFTWARE.
@@ -0,0 +1,58 @@
1
+ blastramp
2
+ =========
3
+
4
+ Ruby wrapper for the [blastramp](http://blastramp.com) SOAP API
5
+
6
+ Blastramp is a Shipping Services Client Library for polling inventory and submitting shipping orders.
7
+
8
+ Usage example
9
+ -------------
10
+
11
+ blastramp = Blastramp::Session.new('vendor_code', 'vendor_access_key')
12
+ blastramp.connect
13
+
14
+ # Get array of inventory counts for a product SKU at all warehouses:
15
+ inventory_counts = blastramp.find_inventory_counts_for_sku('AAA-01-XX')
16
+
17
+ If a warehouse parameter is given, will return a single warehouse inventory_count
18
+ inventory_count = blastramp.find_inventory_counts_for_sku('AAA-01-XX','0001')
19
+
20
+ # Create order:
21
+ order = Blastramp::OrderUpload.new
22
+ order.session = blastramp
23
+
24
+ order.order_id = '123'
25
+ order.order_date = Time.now.strftime("%m/%d/%Y")
26
+ order.start_date = Time.now.strftime("%m/%d/%Y")
27
+ order.expiry_date = 1.month.from_now.strftime("%m/%d/%Y")
28
+ order.num_of_cartons = 1
29
+ order.weight = 1
30
+ order.ship_method = order.shipping_service
31
+ order.warehouse_id = '0001'
32
+
33
+ ship_address = Blastramp::Address.new
34
+ ship_address.name = 'John Smith'
35
+ ship_address.line1 = '1222 Oak Street'
36
+ ship_address.line2 = 'Apt 205'
37
+ ship_address.city = 'Springfield'
38
+ ship_address.provstate = 'IL'
39
+ ship_address.postalcode = '45678'
40
+ ship_address.country = 'USA'
41
+ ship_address.phone = '555-555-5555'
42
+ order.ship_address = ship_address
43
+
44
+ order_item = Blastramp::OrderItem.new
45
+ order_item.order_id = '123'
46
+ order_item.sku = 'AAA-01-XX'
47
+ order_item.quantity = 2
48
+ order_item.item_value = 12.99
49
+ order_item.warehouse_id = '0001'
50
+ order.order_items << order_item
51
+
52
+ order.save
53
+
54
+ Credits
55
+ -------
56
+
57
+ Sponsored by [zkron.com](http://zkron.com)
58
+
@@ -0,0 +1,2 @@
1
+ require 'bundler'
2
+ Bundler::GemHelper.install_tasks
@@ -0,0 +1,26 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "blastramp/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "blastramp"
7
+ s.version = Blastramp::VERSION
8
+ s.platform = Gem::Platform::RUBY
9
+ s.authors = ["cnantais"]
10
+ s.email = ["cnantais@gmail.com"]
11
+ s.homepage = "http://zkron.com"
12
+ s.summary = %q{Blastramp Shipping Services Client Library}
13
+ s.description = %q{Blastramp Shipping Services Client Library for polling inventory and submitting shipping orders.}
14
+
15
+ s.rubyforge_project = "blastramp"
16
+
17
+ s.files = `git ls-files`.split("\n")
18
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
19
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
20
+ s.require_paths = ["lib"]
21
+
22
+ s.add_development_dependency "rspec", "~> 2.3.0"
23
+ s.add_development_dependency "mocha", "~> 0.9.8"
24
+ s.add_development_dependency "savon", "~> 0.8.0.beta.3"
25
+ s.add_development_dependency "savon_spec", "~> 0.1.6"
26
+ end
@@ -0,0 +1,7 @@
1
+ $LOAD_PATH << File.expand_path(File.join(*%w[ .. lib ]), File.dirname(__FILE__))
2
+ require 'savon'
3
+ require 'blastramp/inventory_count_query'
4
+ require 'blastramp/session'
5
+
6
+ module Blastramp
7
+ end
@@ -0,0 +1,4 @@
1
+ module Blastramp
2
+ class InventoryCountQuery
3
+ end
4
+ end
@@ -0,0 +1,34 @@
1
+ module Blastramp
2
+ class Session
3
+ attr_accessor :vendor_code, :vendor_access_key
4
+
5
+ def initialize(vendor_code, vendor_access_key)
6
+ self.vendor_code = vendor_code
7
+ self.vendor_access_key = vendor_access_key
8
+ end
9
+
10
+ # Returns the Savon::Client used to connect to Blastramp
11
+ def client
12
+ @client ||= Savon::Client.new do
13
+ wsdl.endpoint = "http://www.ioperate.net/ws/inventory/inventoryws.asmx"
14
+ wsdl.namespace = "http://chrome52/webservices"
15
+ end
16
+ end
17
+
18
+ # Authenticates with Blastramp
19
+ def connect
20
+ response = client.request :connect do
21
+ soap.body = {
22
+ 'VendorCode' => self.vendor_code,
23
+ 'VendorAccessKey' => self.vendor_access_key
24
+ }
25
+ end
26
+ end
27
+
28
+ # Provides access to the debtors
29
+ def inventory_counts
30
+ @inventory_counts ||= InventoryCountQuery.new(self)
31
+ end
32
+
33
+ end
34
+ end
@@ -0,0 +1,3 @@
1
+ module Blastramp
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,38 @@
1
+ require './spec/spec_helper'
2
+
3
+ describe Blastramp::Session do
4
+ subject { Blastramp::Session.new('ABC', 'TWX45IX2R9G35394') }
5
+
6
+ describe "new" do
7
+ it "should store authentication details" do
8
+ subject.vendor_code.should == 'ABC'
9
+ subject.vendor_access_key.should == 'TWX45IX2R9G35394'
10
+ end
11
+ end
12
+
13
+ describe "client" do
14
+ subject { Blastramp::Session.new('ABC', 'TWX45IX2R9G35394') }
15
+
16
+ it "returns a Savon::Client" do
17
+ subject.client.should be_instance_of(::Savon::Client)
18
+ end
19
+ end
20
+
21
+ describe "connect" do
22
+ it "connects to Blastramp" do
23
+ savon.expects('connect').with(has_entries('VendorCode' => 'ABC','VendorAccessKey' => 'TWX45IX2R9G35394')).returns(:success)
24
+ subject.connect
25
+ end
26
+ end
27
+
28
+ describe "inventory_counts" do
29
+ it "returns an InventoryCountQuery" do
30
+ subject.inventory_counts.should be_instance_of(Blastramp::InventoryCountQuery)
31
+ end
32
+
33
+ it "memoizes the proxy" do
34
+ subject.inventory_counts.should === subject.inventory_counts
35
+ end
36
+ end
37
+
38
+ end
@@ -0,0 +1,9 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
3
+ xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
4
+ <soap:Body>
5
+ <ConnectResponse xmlns="http://chrome52/webservices/">
6
+ <ConnectResult>SUCCESS</ConnectResult>
7
+ </ConnectResponse>
8
+ </soap:Body>
9
+ </soap:Envelope>
@@ -0,0 +1,36 @@
1
+ require 'savon'
2
+ require 'savon_spec'
3
+ require './lib/blastramp'
4
+
5
+ RSpec.configure do |config|
6
+ config.mock_with :mocha
7
+ config.include Savon::Spec::Macros
8
+
9
+ config.before :each do
10
+ # Ensure we don't actually send requests over the network
11
+ HTTPI.expects(:get).never
12
+ HTTPI.expects(:post).never
13
+ end
14
+
15
+ end
16
+
17
+ Savon.configure do |config|
18
+ config.logger = Logger.new(File.join('spec', 'debug.log'))
19
+ end
20
+
21
+ Savon::Spec::Fixture.path = File.expand_path("../fixtures", __FILE__)
22
+
23
+ module Savon
24
+ module WSDL
25
+ class Request
26
+ def response
27
+ # Return the fixture WSDL rather than the online one
28
+ HTTPI::Response.new(200, {}, Savon::Spec::Fixture['wsdl'])
29
+ end
30
+ end
31
+ end
32
+ end
33
+
34
+ def stub_session
35
+ Blastramp::Session.new('ABC', 'TWX45IX2R9G35394')
36
+ end
metadata ADDED
@@ -0,0 +1,141 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: blastramp
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 0
8
+ - 1
9
+ version: 0.0.1
10
+ platform: ruby
11
+ authors:
12
+ - cnantais
13
+ autorequire:
14
+ bindir: bin
15
+ cert_chain: []
16
+
17
+ date: 2011-06-29 00:00:00 -07:00
18
+ default_executable:
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: rspec
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ none: false
25
+ requirements:
26
+ - - ~>
27
+ - !ruby/object:Gem::Version
28
+ segments:
29
+ - 2
30
+ - 3
31
+ - 0
32
+ version: 2.3.0
33
+ type: :development
34
+ version_requirements: *id001
35
+ - !ruby/object:Gem::Dependency
36
+ name: mocha
37
+ prerelease: false
38
+ requirement: &id002 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ~>
42
+ - !ruby/object:Gem::Version
43
+ segments:
44
+ - 0
45
+ - 9
46
+ - 8
47
+ version: 0.9.8
48
+ type: :development
49
+ version_requirements: *id002
50
+ - !ruby/object:Gem::Dependency
51
+ name: savon
52
+ prerelease: false
53
+ requirement: &id003 !ruby/object:Gem::Requirement
54
+ none: false
55
+ requirements:
56
+ - - ~>
57
+ - !ruby/object:Gem::Version
58
+ segments:
59
+ - 0
60
+ - 8
61
+ - 0
62
+ - beta
63
+ - 3
64
+ version: 0.8.0.beta.3
65
+ type: :development
66
+ version_requirements: *id003
67
+ - !ruby/object:Gem::Dependency
68
+ name: savon_spec
69
+ prerelease: false
70
+ requirement: &id004 !ruby/object:Gem::Requirement
71
+ none: false
72
+ requirements:
73
+ - - ~>
74
+ - !ruby/object:Gem::Version
75
+ segments:
76
+ - 0
77
+ - 1
78
+ - 6
79
+ version: 0.1.6
80
+ type: :development
81
+ version_requirements: *id004
82
+ description: Blastramp Shipping Services Client Library for polling inventory and submitting shipping orders.
83
+ email:
84
+ - cnantais@gmail.com
85
+ executables: []
86
+
87
+ extensions: []
88
+
89
+ extra_rdoc_files: []
90
+
91
+ files:
92
+ - .gitignore
93
+ - Gemfile
94
+ - Gemfile.lock
95
+ - LICENSE
96
+ - README.md
97
+ - Rakefile
98
+ - blastramp.gemspec
99
+ - lib/blastramp.rb
100
+ - lib/blastramp/inventory_count_query.rb
101
+ - lib/blastramp/session.rb
102
+ - lib/blastramp/version.rb
103
+ - spec/blastramp/session_spec.rb
104
+ - spec/fixtures/connect/success.xml
105
+ - spec/spec_helper.rb
106
+ has_rdoc: true
107
+ homepage: http://zkron.com
108
+ licenses: []
109
+
110
+ post_install_message:
111
+ rdoc_options: []
112
+
113
+ require_paths:
114
+ - lib
115
+ required_ruby_version: !ruby/object:Gem::Requirement
116
+ none: false
117
+ requirements:
118
+ - - ">="
119
+ - !ruby/object:Gem::Version
120
+ segments:
121
+ - 0
122
+ version: "0"
123
+ required_rubygems_version: !ruby/object:Gem::Requirement
124
+ none: false
125
+ requirements:
126
+ - - ">="
127
+ - !ruby/object:Gem::Version
128
+ segments:
129
+ - 0
130
+ version: "0"
131
+ requirements: []
132
+
133
+ rubyforge_project: blastramp
134
+ rubygems_version: 1.3.7
135
+ signing_key:
136
+ specification_version: 3
137
+ summary: Blastramp Shipping Services Client Library
138
+ test_files:
139
+ - spec/blastramp/session_spec.rb
140
+ - spec/fixtures/connect/success.xml
141
+ - spec/spec_helper.rb