spreadshirt_client 0.0.7 → 0.0.8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: e973d5d1212f875b71adfea5f7d45fe1260ac1a5
4
+ data.tar.gz: 1ac5b19cfbc57026f19dbfe21bed7406e2bc8a5b
5
+ SHA512:
6
+ metadata.gz: 2253aa057c1ccdff74677248f8cba68e04924508c3c04b6973615a7e7425880d8bd9e0fd84e5c91fa668b78e16d4e02296cfeae13b8fbd2db4f708003ab77b24
7
+ data.tar.gz: d00446aeca21b2489bae5ac9e0a992ebb76e06b9ef8175e9616a7bb7a43e80af905e96efb508e74b2a696e4b34dd5392b3a6344a57443b140e2a51da2b4e8a62
data/.travis.yml ADDED
@@ -0,0 +1,14 @@
1
+
2
+ rvm:
3
+ - 2.1.10
4
+ - 2.2.5
5
+ - 2.3.1
6
+
7
+ install:
8
+ - travis_retry bundle install
9
+
10
+ script:
11
+ - bundle exec rake test
12
+
13
+ sudo: false
14
+
data/README.md CHANGED
@@ -1,7 +1,10 @@
1
+
1
2
  # SpreadshirtClient
2
3
 
4
+ [![Build Status](https://secure.travis-ci.org/mrkamel/spreadshirt_client.png?branch=master)](http://travis-ci.org/mrkamel/spreadshirt_client)
5
+
3
6
  Use this gem to communicate with the spreadshirt API.
4
- http://developer.spreadshirt.net
7
+ http://developer.spreadshirt.net/
5
8
 
6
9
  ## Installation
7
10
 
@@ -30,7 +33,7 @@ First, you need to setup your API credentials:
30
33
  ```ruby
31
34
  SpreadshirtClient.api_key = "..."
32
35
  SpreadshirtClient.api_secret = "..."
33
- SpreadshirtClient.base_url = "http://api.spreadshirt.net/api/v1" # optional
36
+ SpreadshirtClient.base_url = "https://api.spreadshirt.net/api/v1" # optional
34
37
  SpreadshirtClient.timeout = 5 # optional (default: 30)
35
38
  ```
36
39
 
@@ -13,7 +13,7 @@ module SpreadshirtClient
13
13
  end
14
14
 
15
15
  def timeout
16
- @timeout || 30
16
+ @timeout ||= 30
17
17
  end
18
18
 
19
19
  def base_url=(base_url)
@@ -21,7 +21,7 @@ module SpreadshirtClient
21
21
  end
22
22
 
23
23
  def base_url
24
- @base_url || "http://api.spreadshirt.net/api/v1"
24
+ @base_url ||= "https://api.spreadshirt.net/api/v1"
25
25
  end
26
26
 
27
27
  def authorize(method, path, session = nil)
@@ -53,6 +53,9 @@ module SpreadshirtClient
53
53
 
54
54
  opts = options.dup
55
55
  opts.delete :session
56
+
57
+ opts[:content_type] ||= "application/xml"
58
+
56
59
  opts.merge headers
57
60
  end
58
61
 
@@ -1,3 +1,3 @@
1
1
  module SpreadshirtClient
2
- VERSION = "0.0.7"
2
+ VERSION = "0.0.8"
3
3
  end
@@ -21,6 +21,7 @@ Gem::Specification.new do |s|
21
21
 
22
22
  s.add_development_dependency "rake"
23
23
  s.add_development_dependency "mocha"
24
+ s.add_development_dependency "minitest"
24
25
  s.add_dependency "rest-client"
25
26
  end
26
27
 
@@ -1,9 +1,16 @@
1
1
 
2
2
  require File.expand_path("../../lib/spreadshirt_client", __FILE__)
3
- require "test/unit"
4
- require "mocha"
3
+ require "minitest"
4
+ require "minitest/autorun"
5
+ require "mocha/mini_test"
5
6
 
6
- class SpreadshirtClientTest < Test::Unit::TestCase
7
+ class SpreadshirtClient::TestCase < MiniTest::Test
8
+ def assert_nothing_raised
9
+ yield
10
+ end
11
+ end
12
+
13
+ class SpreadshirtClientTest < SpreadshirtClient::TestCase
7
14
  def setup
8
15
  SpreadshirtClient.api_key = "test"
9
16
  SpreadshirtClient.api_secret = "test"
@@ -20,39 +27,39 @@ class SpreadshirtClientTest < Test::Unit::TestCase
20
27
  end
21
28
 
22
29
  def test_base_url
23
- assert_equal "http://api.spreadshirt.net/api/v1", SpreadshirtClient.base_url
30
+ assert_equal "https://api.spreadshirt.net/api/v1", SpreadshirtClient.base_url
24
31
 
25
- SpreadshirtClient.base_url = "http://test.spreadshirt.net/api/v1"
32
+ SpreadshirtClient.base_url = "https://test.spreadshirt.net/api/v1"
26
33
 
27
- assert_equal "http://test.spreadshirt.net/api/v1", SpreadshirtClient.base_url
34
+ assert_equal "https://test.spreadshirt.net/api/v1", SpreadshirtClient.base_url
28
35
 
29
- SpreadshirtClient.base_url = "http://api.spreadshirt.net/api/v1"
36
+ SpreadshirtClient.base_url = "https://api.spreadshirt.net/api/v1"
30
37
  end
31
38
 
32
39
  def test_authorize
33
- assert_equal 'SprdAuth apiKey="test", data="post http://api.spreadshirt.net/api/v1/baskets/1/items 1325376000", sig="932555fa9cc0854b03473487af521045dc12d3d0"', SpreadshirtClient.authorize(:post, "/baskets/1/items")
40
+ assert_equal 'SprdAuth apiKey="test", data="post https://api.spreadshirt.net/api/v1/baskets/1/items 1325376000", sig="4c61addd7c13c7cf01363b0e140dfbfb24c6e377"', SpreadshirtClient.authorize(:post, "/baskets/1/items")
34
41
  end
35
42
 
36
43
  def test_authorize_with_session
37
- regex = /\ASprdAuth apiKey=\"test\", data=\"post http:\/\/api.spreadshirt.net\/api\/v1\/orders [0-9]+\", sig=\"[0-9a-f]{40}\", sessionId=\"abcd-1234\"\Z/
44
+ regex = /\ASprdAuth apiKey=\"test\", data=\"post https:\/\/api.spreadshirt.net\/api\/v1\/orders [0-9]+\", sig=\"[0-9a-f]{40}\", sessionId=\"abcd-1234\"\Z/
38
45
 
39
46
  assert SpreadshirtClient.authorize(:post, "/orders", "abcd-1234") =~ regex
40
47
  end
41
48
 
42
49
  def test_url_for
43
- assert_equal "http://api.spreadshirt.net/api/v1/basket/1/items", SpreadshirtClient.url_for("/basket/1/items")
44
- assert_equal "http://test.spreadshirt.net/api/v1/basket/1/items", SpreadshirtClient.url_for("http://test.spreadshirt.net/api/v1/basket/1/items")
50
+ assert_equal "https://api.spreadshirt.net/api/v1/basket/1/items", SpreadshirtClient.url_for("/basket/1/items")
51
+ assert_equal "https://test.spreadshirt.net/api/v1/basket/1/items", SpreadshirtClient.url_for("https://test.spreadshirt.net/api/v1/basket/1/items")
45
52
  end
46
53
 
47
54
  def test_headers_for
48
55
  headers = SpreadshirtClient.headers_for(:post, "/basket/1/items", :authorization => true, :session => "abcd-1234")
49
56
 
50
- assert_equal [:authorization], headers.keys
57
+ assert_equal [:authorization, :content_type], headers.keys
51
58
 
52
59
  assert headers[:authorization].include?("SprdAuth")
53
60
  assert headers[:authorization].include?("abcd-1234")
54
61
 
55
- assert_equal({ :params => { :limit => 500 } }, SpreadshirtClient.headers_for(:get, "/shops/1/articles", :params => { :limit => 500 }))
62
+ assert_equal({ :params => { :limit => 500 }, :content_type => "application/xml" }, SpreadshirtClient.headers_for(:get, "/shops/1/articles", :params => { :limit => 500 }))
56
63
  end
57
64
 
58
65
  def test_method_for
@@ -70,25 +77,25 @@ class SpreadshirtClientTest < Test::Unit::TestCase
70
77
  end
71
78
 
72
79
  def test_put
73
- RestClient.expects(:put).with("http://api.spreadshirt.net/api/v1/baskets/1/items/1", "payload", :authorization => 'SprdAuth apiKey="test", data="PUT http://api.spreadshirt.net/api/v1/baskets/1/items/1 1325376000", sig="2f7a28edc68bbec83a8a580bbd1506ba9192f68e"').returns(200)
80
+ RestClient.expects(:put).with("https://api.spreadshirt.net/api/v1/baskets/1/items/1", "payload", :authorization => 'SprdAuth apiKey="test", data="PUT https://api.spreadshirt.net/api/v1/baskets/1/items/1 1325376000", sig="e8d0b7f085f976b4486ed8e58b187fcf8181f576"', :content_type => "application/xml").returns(200)
74
81
 
75
82
  assert_equal 200, SpreadshirtClient.put("/baskets/1/items/1", "payload", :authorization => true)
76
83
  end
77
84
 
78
85
  def test_post
79
- RestClient.expects(:post).with("http://api.spreadshirt.net/api/v1/baskets", "payload", :authorization => 'SprdAuth apiKey="test", data="POST http://api.spreadshirt.net/api/v1/baskets 1325376000", sig="04097ac87eadc5d6d0766b2dabf509ebc35eb3bc"').returns(200)
86
+ RestClient.expects(:post).with("https://api.spreadshirt.net/api/v1/baskets", "payload", :authorization => 'SprdAuth apiKey="test", data="POST https://api.spreadshirt.net/api/v1/baskets 1325376000", sig="261791c8c28dd7e813c5bff70c012a6a431dea66"', :content_type => "application/xml").returns(200)
80
87
 
81
88
  assert_equal 200, SpreadshirtClient.post("/baskets", "payload", :authorization => true)
82
89
  end
83
90
 
84
91
  def test_get
85
- RestClient.expects(:get).with("http://api.spreadshirt.net/api/v1/orders/1", :authorization => 'SprdAuth apiKey="test", data="GET http://api.spreadshirt.net/api/v1/orders/1 1325376000", sig="7f06c7604b97b682c545262bd9acbbaf04eb8fcd", sessionId="abcd-1234"').returns(200)
92
+ RestClient.expects(:get).with("https://api.spreadshirt.net/api/v1/orders/1", :authorization => 'SprdAuth apiKey="test", data="GET https://api.spreadshirt.net/api/v1/orders/1 1325376000", sig="594442cc4dfb6c09163e753f50199ce9caf1c14f", sessionId="abcd-1234"', :content_type => "application/xml").returns(200)
86
93
 
87
94
  assert_equal 200, SpreadshirtClient.get("/orders/1", :authorization => true, :session => "abcd-1234")
88
95
  end
89
96
 
90
97
  def test_delete
91
- RestClient.expects(:delete).with("http://api.spreadshirt.net/api/v1/baskets/1/items/1", :authorization => 'SprdAuth apiKey="test", data="DELETE http://api.spreadshirt.net/api/v1/baskets/1/items/1 1325376000", sig="010f76d9c0a01278872a897b72bcac4daf0109cf"').returns(200)
98
+ RestClient.expects(:delete).with("https://api.spreadshirt.net/api/v1/baskets/1/items/1", :authorization => 'SprdAuth apiKey="test", data="DELETE https://api.spreadshirt.net/api/v1/baskets/1/items/1 1325376000", sig="0675841d32f61f15d047ea0b6419fc22f78e2ed6"', :content_type => "application/xml").returns(200)
92
99
 
93
100
  assert_equal 200, SpreadshirtClient.delete("/baskets/1/items/1", :authorization => true)
94
101
  end
metadata CHANGED
@@ -1,62 +1,69 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spreadshirt_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
5
- prerelease:
4
+ version: 0.0.8
6
5
  platform: ruby
7
6
  authors:
8
7
  - Benjamin Vetter
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-11-12 00:00:00.000000000 Z
11
+ date: 2016-12-01 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: rake
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ! '>='
17
+ - - ">="
20
18
  - !ruby/object:Gem::Version
21
19
  version: '0'
22
20
  type: :development
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ! '>='
24
+ - - ">="
28
25
  - !ruby/object:Gem::Version
29
26
  version: '0'
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: mocha
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ! '>='
31
+ - - ">="
36
32
  - !ruby/object:Gem::Version
37
33
  version: '0'
38
34
  type: :development
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ! '>='
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: minitest
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
44
53
  - !ruby/object:Gem::Version
45
54
  version: '0'
46
55
  - !ruby/object:Gem::Dependency
47
56
  name: rest-client
48
57
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
58
  requirements:
51
- - - ! '>='
59
+ - - ">="
52
60
  - !ruby/object:Gem::Version
53
61
  version: '0'
54
62
  type: :runtime
55
63
  prerelease: false
56
64
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
65
  requirements:
59
- - - ! '>='
66
+ - - ">="
60
67
  - !ruby/object:Gem::Version
61
68
  version: '0'
62
69
  description: Communicate with the spreadshirt API using a DSL similar to the one of
@@ -67,7 +74,8 @@ executables: []
67
74
  extensions: []
68
75
  extra_rdoc_files: []
69
76
  files:
70
- - .gitignore
77
+ - ".gitignore"
78
+ - ".travis.yml"
71
79
  - Gemfile
72
80
  - LICENSE
73
81
  - README.md
@@ -79,26 +87,25 @@ files:
79
87
  homepage: https://github.com/mrkamel/spreadshirt_client
80
88
  licenses:
81
89
  - MIT
90
+ metadata: {}
82
91
  post_install_message:
83
92
  rdoc_options: []
84
93
  require_paths:
85
94
  - lib
86
95
  required_ruby_version: !ruby/object:Gem::Requirement
87
- none: false
88
96
  requirements:
89
- - - ! '>='
97
+ - - ">="
90
98
  - !ruby/object:Gem::Version
91
99
  version: '0'
92
100
  required_rubygems_version: !ruby/object:Gem::Requirement
93
- none: false
94
101
  requirements:
95
- - - ! '>='
102
+ - - ">="
96
103
  - !ruby/object:Gem::Version
97
104
  version: '0'
98
105
  requirements: []
99
106
  rubyforge_project: spreadshirt_client
100
- rubygems_version: 1.8.23
107
+ rubygems_version: 2.2.2
101
108
  signing_key:
102
- specification_version: 3
109
+ specification_version: 4
103
110
  summary: Communicate with the spreadshirt API
104
111
  test_files: []