shirtsio 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +11 -0
- data/Gemfile +6 -1
- data/README.md +3 -1
- data/Rakefile +2 -0
- data/lib/shirtsio/product.rb +1 -0
- data/lib/shirtsio/request.rb +8 -20
- data/lib/shirtsio/version.rb +1 -1
- data/spec/configuration_spec.rb +10 -0
- data/spec/dsl_spec.rb +7 -0
- data/spec/order_spec.rb +52 -0
- data/spec/product_spec.rb +25 -0
- data/spec/quote_spec.rb +23 -0
- data/spec/spec_helper.rb +22 -4
- data/spec/status_spec.rb +28 -0
- data/spec/support/ruby.jpg +0 -0
- data/spec/support/ruby.png +0 -0
- data/spec/support/travis.rb +7 -0
- metadata +18 -2
- data/e +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4be6149f4625de501167a9c29c1766958b1e45a0
|
4
|
+
data.tar.gz: af8ce14c981ce2c081e1791c7fe60ebda55d88ab
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 41f2e1da3a993ed8fe95cc10ebaf14f4a28ff7b12124de8911cada51dcf1a0c9ed07edad81f4e7b9b2cea1e4a129e2d4835004127206bd7811bf6f39167a86d2
|
7
|
+
data.tar.gz: dc7554f85245e013c6024f28ae234b540847772e7c3be717af593d478304f504fce83c08cfa2acf771dfc467b23936bdcd9f300ba786e88d192c1f2b3592bd60
|
data/.travis.yml
ADDED
data/Gemfile
CHANGED
@@ -3,12 +3,17 @@ source 'https://rubygems.org'
|
|
3
3
|
# Specify your gem's dependencies in shirtsio.gemspec
|
4
4
|
gemspec
|
5
5
|
|
6
|
+
platforms :rbx do
|
7
|
+
gem 'json'
|
8
|
+
end
|
9
|
+
|
6
10
|
group :development do
|
7
|
-
gem 'bundler'
|
11
|
+
gem 'bundler'
|
8
12
|
gem 'rake'
|
9
13
|
gem 'yard'
|
10
14
|
end
|
11
15
|
|
12
16
|
group :test do
|
13
17
|
gem 'rspec'
|
18
|
+
gem 'simplecov'
|
14
19
|
end
|
data/README.md
CHANGED
@@ -1,7 +1,9 @@
|
|
1
|
-
# Shirtsio
|
1
|
+
# Shirtsio [![endorse](http://api.coderwall.com/anthonator/endorsecount.png)](http://coderwall.com/anthonator)
|
2
2
|
|
3
3
|
A Ruby wrapper around the shirts.io API
|
4
4
|
|
5
|
+
[![Build Status](https://travis-ci.org/anthonator/shirtsio.png?branch=master)](https://travis-ci.org/anthonator/shirtsio)
|
6
|
+
|
5
7
|
## Documentation
|
6
8
|
|
7
9
|
You can view detailed documentation of this library at http://rdoc.info/github/anthonator/shirtsio/frames. We try to make sure that our documentation is up-to-date and thorough. However, we do recommend keeping the [shirts.io API documentation](https://www.shirts.io/docs/overview/) handy.
|
data/Rakefile
CHANGED
data/lib/shirtsio/product.rb
CHANGED
data/lib/shirtsio/request.rb
CHANGED
@@ -1,16 +1,16 @@
|
|
1
1
|
module Shirtsio
|
2
2
|
module Request
|
3
|
-
def get(path, options = {}, headers = {}
|
4
|
-
request(:get, path, options, headers
|
3
|
+
def get(path, options = {}, headers = {})
|
4
|
+
request(:get, path, options, headers)
|
5
5
|
end
|
6
6
|
|
7
|
-
def post(path, options = {}, headers = {}
|
8
|
-
request(:post, path, options, headers
|
7
|
+
def post(path, options = {}, headers = {})
|
8
|
+
request(:post, path, options, headers)
|
9
9
|
end
|
10
10
|
|
11
11
|
private
|
12
12
|
# Perform an HTTP request
|
13
|
-
def request(method, path, options, headers
|
13
|
+
def request(method, path, options, headers)
|
14
14
|
headers.merge!({
|
15
15
|
'User-Agent' => user_agent
|
16
16
|
})
|
@@ -20,25 +20,13 @@ module Shirtsio
|
|
20
20
|
})
|
21
21
|
|
22
22
|
response = connection.send(method) do |request|
|
23
|
-
|
24
|
-
|
25
|
-
else
|
26
|
-
request.url "#{endpoint}#{path}"
|
27
|
-
request.body = options
|
28
|
-
end
|
23
|
+
request.url "#{endpoint}#{path}", options
|
24
|
+
request.body = options
|
29
25
|
request.headers = headers
|
30
26
|
end
|
31
27
|
Shirtsio::Utils.handle_api_error(response) if response.status != 200
|
32
28
|
|
33
|
-
|
34
|
-
result = response.body
|
35
|
-
else
|
36
|
-
# The API is returning the "result" encoded as a string rather than
|
37
|
-
# object notation so it requires a second pass of the JSON parser
|
38
|
-
result = Shirtsio::Utils.parse_json(response.body)[:result]
|
39
|
-
end
|
40
|
-
|
41
|
-
result
|
29
|
+
Shirtsio::Utils.parse_json(response.body)[:result]
|
42
30
|
end
|
43
31
|
end
|
44
32
|
end
|
data/lib/shirtsio/version.rb
CHANGED
data/spec/dsl_spec.rb
CHANGED
@@ -32,4 +32,11 @@ describe Shirtsio::DSL::QueryBuilder do
|
|
32
32
|
end.to_hash)
|
33
33
|
URI::unescape(query).should == 'a_method[b_method][0]=value'
|
34
34
|
end
|
35
|
+
|
36
|
+
it "should translate File to Faraday::UploadIO" do
|
37
|
+
query = Shirtsio::DSL::QueryBuilder.new([:a_method]) do |builder|
|
38
|
+
builder.a_method File.new(File.expand_path('support/ruby.png', File.dirname(__FILE__)))
|
39
|
+
end.to_hash
|
40
|
+
query[:a_method].class.should == Faraday::UploadIO
|
41
|
+
end
|
35
42
|
end
|
data/spec/order_spec.rb
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Shirtsio::Order, :skip_if_travis => true do
|
4
|
+
it "should create an order" do
|
5
|
+
order = Shirtsio::Order.create do |order|
|
6
|
+
order.test true
|
7
|
+
order.price 28.43
|
8
|
+
order.print_type 'Digital Print'
|
9
|
+
order.ship_type 'Standard'
|
10
|
+
order.garment do |garment|
|
11
|
+
garment.product_id 1
|
12
|
+
garment.color 'Black'
|
13
|
+
garment.sizes do |size|
|
14
|
+
size.med 1
|
15
|
+
end
|
16
|
+
end
|
17
|
+
order.print do |print|
|
18
|
+
print.front do |front|
|
19
|
+
front.artwork File.new(File.expand_path('support/ruby.png', File.dirname(__FILE__)))
|
20
|
+
front.proof File.new(File.expand_path('support/ruby.jpg', File.dirname(__FILE__)))
|
21
|
+
front.color_count 1
|
22
|
+
front.colors ['Black']
|
23
|
+
front.dimensions '5.0 inches wide'
|
24
|
+
front.placement '4.0 inches below bottom of collar'
|
25
|
+
end
|
26
|
+
end
|
27
|
+
order.personalization do |personalization|
|
28
|
+
personalization.size 'med'
|
29
|
+
personalization.batch 1
|
30
|
+
personalization.number 1
|
31
|
+
personalization.number_size 2
|
32
|
+
personalization.name 'Bob'
|
33
|
+
personalization.name_size 1
|
34
|
+
end
|
35
|
+
order.addresses do |address|
|
36
|
+
address.name 'Anthony'
|
37
|
+
address.company 'Sticksnleaves'
|
38
|
+
address.address '1234 Hopes and Dreams Ln.'
|
39
|
+
address.address2 'Apt. <3'
|
40
|
+
address.city 'Seattle'
|
41
|
+
address.state 'Washington'
|
42
|
+
address.zipcode 55555
|
43
|
+
address.country 'US'
|
44
|
+
address.batch 1
|
45
|
+
address.sizes do |size|
|
46
|
+
size.med 1
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
order.class.should == Shirtsio::Order
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Shirtsio::Product, :skip_if_travis => true do
|
4
|
+
it "should find a specific product" do
|
5
|
+
product = Shirtsio::Product.find(1)
|
6
|
+
product.class.should == Shirtsio::Product
|
7
|
+
end
|
8
|
+
|
9
|
+
describe Shirtsio::Product::Category do
|
10
|
+
it "should return a list of categories" do
|
11
|
+
categories = Shirtsio::Product::Category.list
|
12
|
+
categories[0].class.should == Shirtsio::Product::Category
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should return a list of products" do
|
16
|
+
categories = Shirtsio::Product::Category.list
|
17
|
+
categories[0].products[0].class.should == Shirtsio::Product::Simple
|
18
|
+
end
|
19
|
+
|
20
|
+
it "should return a complete product object" do
|
21
|
+
categories = Shirtsio::Product::Category.list
|
22
|
+
categories[0].products[0].full_product.class.should == Shirtsio::Product
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
data/spec/quote_spec.rb
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Shirtsio::Quote do
|
4
|
+
it "should retrieve a quote" do
|
5
|
+
quote = Shirtsio::Quote.create do |quote|
|
6
|
+
quote.print_type 'Digital Print'
|
7
|
+
quote.garment do |garment|
|
8
|
+
garment.product_id 1
|
9
|
+
garment.color 'Black'
|
10
|
+
garment.sizes do |size|
|
11
|
+
size.med 1
|
12
|
+
end
|
13
|
+
end
|
14
|
+
quote.print do |print|
|
15
|
+
print.front do |front|
|
16
|
+
front.color_count 1
|
17
|
+
front.colors ['Black']
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
quote.class.should == Shirtsio::Quote
|
22
|
+
end
|
23
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,11 +1,29 @@
|
|
1
|
-
ENV['RAILS_ENV'] = 'test'
|
2
|
-
|
3
|
-
require 'shirtsio'
|
4
|
-
|
5
1
|
# Require supporting ruby files with custom matchers and macros, etc,
|
6
2
|
# in spec/support/ and its subdirectories.
|
7
3
|
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
|
8
4
|
|
5
|
+
require 'simplecov'
|
6
|
+
SimpleCov.start do
|
7
|
+
if Support::Travis::travis?
|
8
|
+
add_filter do |source_file|
|
9
|
+
['product_spec.rb', 'product.rb', 'order_spec.rb', 'order.rb', 'status_spec.rb', 'status.rb'].include?(File.basename(source_file.filename))
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
ENV['RAILS_ENV'] = 'test'
|
15
|
+
|
16
|
+
require 'tempfile'
|
17
|
+
require 'shirtsio'
|
18
|
+
|
9
19
|
RSpec.configure do |config|
|
20
|
+
config.before(:each) do
|
21
|
+
Shirtsio.configure do |config|
|
22
|
+
config.api_key = '...'
|
23
|
+
end
|
24
|
+
end
|
10
25
|
|
26
|
+
if Support::Travis::travis?
|
27
|
+
config.filter_run_excluding :skip_if_travis => true
|
28
|
+
end
|
11
29
|
end
|
data/spec/status_spec.rb
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Shirtsio::Status, :skip_if_travis => true do
|
4
|
+
describe Shirtsio::Status::Webhook do
|
5
|
+
it "should register a webhook" do
|
6
|
+
Shirtsio::Status::Webhook.create('http://www.example.com').should be_true
|
7
|
+
Shirtsio::Status::Webhook.delete('http://www.example.com') # teardown
|
8
|
+
end
|
9
|
+
|
10
|
+
it "should return a list of webhooks" do
|
11
|
+
Shirtsio::Status::Webhook.create('http://www.example.com') # seed
|
12
|
+
webhooks = Shirtsio::Status::Webhook.list
|
13
|
+
webhooks[0].class.should == Shirtsio::Status::Webhook
|
14
|
+
Shirtsio::Status::Webhook.delete('http://www.example.com') # teardown
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should delete a webhook" do
|
18
|
+
Shirtsio::Status::Webhook.create('http://www.example.com') # seed
|
19
|
+
Shirtsio::Status::Webhook.delete('http://www.example.com').should be_true # teardown
|
20
|
+
end
|
21
|
+
|
22
|
+
it "should delete a webhook by instance" do
|
23
|
+
Shirtsio::Status::Webhook.create('http://www.example.com') # seed
|
24
|
+
webhooks = Shirtsio::Status::Webhook.list
|
25
|
+
webhooks[0].delete.should be_true
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
Binary file
|
Binary file
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: shirtsio
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Anthony Smith
|
@@ -60,11 +60,11 @@ extensions: []
|
|
60
60
|
extra_rdoc_files: []
|
61
61
|
files:
|
62
62
|
- .gitignore
|
63
|
+
- .travis.yml
|
63
64
|
- Gemfile
|
64
65
|
- LICENSE.txt
|
65
66
|
- README.md
|
66
67
|
- Rakefile
|
67
|
-
- e
|
68
68
|
- lib/shirtsio.rb
|
69
69
|
- lib/shirtsio/api.rb
|
70
70
|
- lib/shirtsio/configuration.rb
|
@@ -80,8 +80,16 @@ files:
|
|
80
80
|
- lib/shirtsio/utils.rb
|
81
81
|
- lib/shirtsio/version.rb
|
82
82
|
- shirtsio.gemspec
|
83
|
+
- spec/configuration_spec.rb
|
83
84
|
- spec/dsl_spec.rb
|
85
|
+
- spec/order_spec.rb
|
86
|
+
- spec/product_spec.rb
|
87
|
+
- spec/quote_spec.rb
|
84
88
|
- spec/spec_helper.rb
|
89
|
+
- spec/status_spec.rb
|
90
|
+
- spec/support/ruby.jpg
|
91
|
+
- spec/support/ruby.png
|
92
|
+
- spec/support/travis.rb
|
85
93
|
homepage: https://github.com/anthonator/shirtsio
|
86
94
|
licenses:
|
87
95
|
- MIT
|
@@ -107,6 +115,14 @@ signing_key:
|
|
107
115
|
specification_version: 4
|
108
116
|
summary: shirts.io REST API client library for Ruby
|
109
117
|
test_files:
|
118
|
+
- spec/configuration_spec.rb
|
110
119
|
- spec/dsl_spec.rb
|
120
|
+
- spec/order_spec.rb
|
121
|
+
- spec/product_spec.rb
|
122
|
+
- spec/quote_spec.rb
|
111
123
|
- spec/spec_helper.rb
|
124
|
+
- spec/status_spec.rb
|
125
|
+
- spec/support/ruby.jpg
|
126
|
+
- spec/support/ruby.png
|
127
|
+
- spec/support/travis.rb
|
112
128
|
has_rdoc:
|
data/e
DELETED
File without changes
|