slipmate 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.txt ADDED
@@ -0,0 +1,48 @@
1
+ slipmate
2
+ by FIXME (your name)
3
+ FIXME (url)
4
+
5
+ == DESCRIPTION:
6
+
7
+ FIXME (describe your package)
8
+
9
+ == FEATURES/PROBLEMS:
10
+
11
+ * FIXME (list of features or problems)
12
+
13
+ == SYNOPSIS:
14
+
15
+ FIXME (code sample of usage)
16
+
17
+ == REQUIREMENTS:
18
+
19
+ * FIXME (list of requirements)
20
+
21
+ == INSTALL:
22
+
23
+ * FIXME (sudo gem install, anything else)
24
+
25
+ == LICENSE:
26
+
27
+ (The MIT License)
28
+
29
+ Copyright (c) 2009 FIXME (different license?)
30
+
31
+ Permission is hereby granted, free of charge, to any person obtaining
32
+ a copy of this software and associated documentation files (the
33
+ 'Software'), to deal in the Software without restriction, including
34
+ without limitation the rights to use, copy, modify, merge, publish,
35
+ distribute, sublicense, and/or sell copies of the Software, and to
36
+ permit persons to whom the Software is furnished to do so, subject to
37
+ the following conditions:
38
+
39
+ The above copyright notice and this permission notice shall be
40
+ included in all copies or substantial portions of the Software.
41
+
42
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
43
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
44
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
45
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
46
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
47
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
48
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Rakefile ADDED
@@ -0,0 +1,17 @@
1
+
2
+ begin
3
+ require 'bones'
4
+ rescue LoadError
5
+ abort '### Please install the "bones" gem ###'
6
+ end
7
+
8
+ task :default => 'test:run'
9
+ task 'gem:release' => 'test:run'
10
+
11
+ Bones {
12
+ name 'slipmate'
13
+ authors 'FIXME (who is writing this software)'
14
+ email 'FIXME (your e-mail)'
15
+ url 'FIXME (project homepage)'
16
+ }
17
+
data/lib/slipmate.rb ADDED
@@ -0,0 +1,28 @@
1
+ $:.unshift File.dirname(__FILE__)
2
+
3
+ begin
4
+ require 'active_support/all'
5
+ rescue LoadError => e
6
+ require 'rubygems'
7
+ gem "activesupport", ">= 2.3.5"
8
+ require "active_support/all"
9
+ end
10
+
11
+ require 'httparty'
12
+
13
+ require 'slipmate/api'
14
+ require 'slipmate/order'
15
+ require 'slipmate/customer'
16
+ require 'slipmate/item'
17
+ # puts Slipmate::Order.create
18
+
19
+ # puts {:shipping_first_name => "spencer", :shipping_last_name => "Markowski", :shipping_address_1 => "10215 Pamona Court", :shipping_city => "Fishers", :shipping_state => "IN", :shipping_zip => "46038", :shipping_tld => "USA", :shipping_method_code => "UPS", :shipping_amount => "1.27", :order_date => DateTime.now.to_s }.stringify_keys!
20
+
21
+ # @order = Slipmate::Order.new({:shipping_first_name => "spencer", :shipping_last_name => "Markowski", :shipping_address_1 => "10215 Pamona Court", :shipping_city => "Fishers", :shipping_state => "IN", :shipping_zip => "46038", :shipping_tld => "USA", :shipping_method_code => "UPS", :shipping_amount => "1.27", :order_date => DateTime.now.to_s })
22
+ # @customer = Slipmate::Customer.new( {:first_name => "spencer", :last_name => "markowski", :address_1 => "10215 Pamona Court", :city => "Fishers", :state => "IN", :zip => "46038" , :tld => "USA", :phone => "317-902-6569"})
23
+ # @item = Slipmate::Item.new({:item_code => "WHITE_SCARF", :quantity => 3, :unit_price => 15})
24
+ # @items = [@item]
25
+ # p Slipmate::API.create_order( @customer, @order, @items )
26
+
27
+
28
+ # puts @order
@@ -0,0 +1,22 @@
1
+ module Slipmate
2
+ class API
3
+ include HTTParty
4
+ base_uri "http://slipmate.biz/api"
5
+ default_params :output => "json"
6
+ API_KEY = "30ds4930sdfs49s09a092309a"
7
+
8
+
9
+ def self.create_order(customer, order , items)
10
+ serialized_items = items.collect{|item| item.serialize }
11
+ puts order.serialize.inspect
12
+ results = self.post("/create_order.json", :body => {:api_key => API_KEY,
13
+ :customer => customer.serialize,
14
+ :order => order.serialize,
15
+ :items => serialized_items },
16
+ :format => :json )
17
+ end
18
+ end
19
+
20
+
21
+ end
22
+
@@ -0,0 +1,30 @@
1
+ module Slipmate
2
+ class Customer
3
+ attr_accessor :first_name,
4
+ :last_name,
5
+ :address_1,
6
+ :address_2,
7
+ :city,
8
+ :state,
9
+ :zip,
10
+ :tld,
11
+ :phone
12
+
13
+
14
+
15
+ def initialize(attributes={})
16
+ attributes.reverse_merge! :tld => "USA"
17
+ attributes.stringify_keys!
18
+ attributes.each_pair{|key,value| send("#{key}=", value) if self.respond_to? "#{key}=" }
19
+ end
20
+
21
+ def serialize
22
+ h={}
23
+ self.instance_variables.each do |variab|
24
+ h[variab.gsub("@","").to_sym] = self.instance_variable_get(variab)
25
+ end
26
+ h
27
+ end
28
+ end
29
+ end
30
+
@@ -0,0 +1,23 @@
1
+ module Slipmate
2
+ class Item
3
+ attr_accessor :item_code,
4
+ :quantity,
5
+ :unit_price
6
+
7
+
8
+ def initialize(attributes={})
9
+ attributes.reverse_merge! :tld => "USA"
10
+ attributes.stringify_keys!
11
+ attributes.each_pair{|key,value| send("#{key}=", value) if self.respond_to? "#{key}=" }
12
+ end
13
+
14
+ def serialize
15
+ h={}
16
+ self.instance_variables.each do |variab|
17
+ h[variab.gsub("@","").to_sym] = self.instance_variable_get(variab)
18
+ end
19
+ h
20
+ end
21
+ end
22
+ end
23
+
@@ -0,0 +1,49 @@
1
+ module Slipmate
2
+ class Order
3
+ attr_accessor :shipping_first_name,
4
+ :shipping_last_name,
5
+ :shipping_address_1,
6
+ :shipping_address_2,
7
+ :shipping_city,
8
+ :shipping_state,
9
+ :shipping_zip,
10
+ :shipping_tld,
11
+ :shipping_method_code,
12
+ :shipping_amount,
13
+ :order_date,
14
+ :shipping_company,
15
+ :shipping_special_instructions,
16
+ :origin_type,
17
+ :xc_identifier,
18
+ :store_code,
19
+ :supplier,
20
+ :is_held,
21
+ :status_hash
22
+
23
+
24
+
25
+
26
+
27
+ def bang
28
+
29
+ end
30
+
31
+ def initialize(attributes={})
32
+ attributes.reverse_merge! :order_date => DateTime.now, :is_held => false
33
+ attributes.stringify_keys!
34
+ attributes.each_pair{|key,value| send("#{key}=", value) if self.respond_to? "#{key}=" }
35
+
36
+ end
37
+
38
+ def serialize
39
+ h={}
40
+ self.instance_variables.each do |variab|
41
+ h[variab.gsub("@","").to_sym] = self.instance_variable_get(variab)
42
+ end
43
+ h
44
+ end
45
+
46
+
47
+ end
48
+ end
49
+
data/slipmate.gemspec ADDED
@@ -0,0 +1,27 @@
1
+ Gem::Specification.new do |s|
2
+ s.name = %q{slipmate}
3
+ s.version = "0.1.1"
4
+
5
+ s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
6
+ s.authors = ["Spencer Markowski"]
7
+ s.date = %q{2010-07-21}
8
+ s.description = %q{Slipmate API}
9
+ s.email = %q{spencer@thablefew.com}
10
+ s.files = ["README.txt", "Rakefile", "lib/slipmate.rb", "slipmate.gemspec", "lib/slipmate/api.rb","lib/slipmate/customer.rb","lib/slipmate/order.rb","lib/slipmate/item.rb"]
11
+ s.has_rdoc = false
12
+ s.homepage = %q{http://slipmate.biz/}
13
+ s.require_paths = ["lib"]
14
+ s.rubyforge_project = %q{slipmate}
15
+ s.rubygems_version = %q{1.3.4}
16
+ s.summary = %q{Create and manage orders in Slipmate}
17
+
18
+ if s.respond_to? :specification_version then
19
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
20
+ s.specification_version = 3
21
+
22
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
23
+ else
24
+ end
25
+ else
26
+ end
27
+ end
metadata ADDED
@@ -0,0 +1,75 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: slipmate
3
+ version: !ruby/object:Gem::Version
4
+ hash: 25
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 1
9
+ - 1
10
+ version: 0.1.1
11
+ platform: ruby
12
+ authors:
13
+ - Spencer Markowski
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2010-07-21 00:00:00 -04:00
19
+ default_executable:
20
+ dependencies: []
21
+
22
+ description: Slipmate API
23
+ email: spencer@thablefew.com
24
+ executables: []
25
+
26
+ extensions: []
27
+
28
+ extra_rdoc_files: []
29
+
30
+ files:
31
+ - README.txt
32
+ - Rakefile
33
+ - lib/slipmate.rb
34
+ - slipmate.gemspec
35
+ - lib/slipmate/api.rb
36
+ - lib/slipmate/customer.rb
37
+ - lib/slipmate/order.rb
38
+ - lib/slipmate/item.rb
39
+ has_rdoc: false
40
+ homepage: http://slipmate.biz/
41
+ licenses: []
42
+
43
+ post_install_message:
44
+ rdoc_options: []
45
+
46
+ require_paths:
47
+ - lib
48
+ required_ruby_version: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ hash: 3
54
+ segments:
55
+ - 0
56
+ version: "0"
57
+ required_rubygems_version: !ruby/object:Gem::Requirement
58
+ none: false
59
+ requirements:
60
+ - - ">="
61
+ - !ruby/object:Gem::Version
62
+ hash: 11
63
+ segments:
64
+ - 1
65
+ - 2
66
+ version: "1.2"
67
+ requirements: []
68
+
69
+ rubyforge_project: slipmate
70
+ rubygems_version: 1.3.7
71
+ signing_key:
72
+ specification_version: 3
73
+ summary: Create and manage orders in Slipmate
74
+ test_files: []
75
+