social_rebate 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -4,7 +4,7 @@ module SocialRebate
4
4
 
5
5
  base_uri "socialrebate.net"
6
6
  format :json
7
- STATUS = ['required', 'VERIFIED', 'VOID', 'COUPON']
7
+ STATUS = ['UNVERIFIED', 'VERIFIED', 'VOID', 'COUPON']
8
8
 
9
9
  class ResponseError < StandardError; end
10
10
 
@@ -65,6 +65,7 @@ module SocialRebate
65
65
  end
66
66
 
67
67
  def post(url, body={}, headers={})
68
+ check_post_url(url)
68
69
  body.merge!(@configuration).merge!({:store_key => @store_key})
69
70
 
70
71
  options = {}
@@ -75,7 +76,7 @@ module SocialRebate
75
76
 
76
77
  def put(url, body={}, headers={})
77
78
  check_body_params(body)
78
- check_url(url)
79
+ check_put_url(url)
79
80
 
80
81
  body = body.merge!(@configuration).merge!({:store_key => @store_key})
81
82
  options = {}
@@ -98,9 +99,15 @@ module SocialRebate
98
99
  end
99
100
  end
100
101
 
101
- def check_url(url)
102
- if url !~ /\/orders\/[0-9a-z-A-Z]+\/$/i
103
- raise ResponseError.new("Incorrect put url: ../api/v2/orders/<your order id>/")
102
+ def check_put_url(url)
103
+ if url !~ /\/v[0-9]+\/orders\/[0-9a-zA-Z]+\/$/i
104
+ raise ResponseError.new("Incorrect put request url, expected: /api/v[0-9]/orders/<your order id>/")
105
+ end
106
+ end
107
+
108
+ def check_post_url(url)
109
+ if url !~ /\/v[0-9]+\/orders\/$/i
110
+ raise ResponseError.new("Incorrect post request url, expected: /api/v[0-9]/orders/")
104
111
  end
105
112
  end
106
113
  end
@@ -1,3 +1,3 @@
1
1
  module SocialRebate
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
10
10
  spec.email = ["daifu.ye@gmail.com"]
11
11
  spec.description = %q{This is the api wrapper for social rebate}
12
12
  spec.summary = %q{Social Rebate}
13
- spec.homepage = "http://www.finditparts.com"
13
+ spec.homepage = "https://github.com/daifu/social_rebate_api_wrapper"
14
14
  spec.license = "MIT"
15
15
 
16
16
  spec.files = `git ls-files`.split($/)
@@ -24,6 +24,6 @@ Gem::Specification.new do |spec|
24
24
  spec.add_development_dependency "debugger"
25
25
 
26
26
  spec.add_dependency "httparty", ">= 0.9.0"
27
- spec.add_dependency "json" , "~> 1.8.0"
27
+ spec.add_dependency "json" , "~> 1.7.0"
28
28
 
29
29
  end
@@ -38,6 +38,12 @@ describe SocialRebate::Connection do
38
38
  @sr.post('/api/v2/orders/', @body)
39
39
  }.to raise_error(SocialRebate::Connection::ResponseError)
40
40
  end
41
+
42
+ it "should raise exception with incorrect url" do
43
+ expect {
44
+ @sr.post('/api/v2/orders', @body)
45
+ }.to raise_error(SocialRebate::Connection::ResponseError)
46
+ end
41
47
  end
42
48
  end
43
49
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: social_rebate
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -98,7 +98,7 @@ dependencies:
98
98
  requirements:
99
99
  - - ~>
100
100
  - !ruby/object:Gem::Version
101
- version: 1.8.0
101
+ version: 1.7.0
102
102
  type: :runtime
103
103
  prerelease: false
104
104
  version_requirements: !ruby/object:Gem::Requirement
@@ -106,7 +106,7 @@ dependencies:
106
106
  requirements:
107
107
  - - ~>
108
108
  - !ruby/object:Gem::Version
109
- version: 1.8.0
109
+ version: 1.7.0
110
110
  description: This is the api wrapper for social rebate
111
111
  email:
112
112
  - daifu.ye@gmail.com
@@ -127,7 +127,7 @@ files:
127
127
  - social_rebate.gemspec
128
128
  - spec/connection_spec.rb
129
129
  - spec/spec_helper.rb
130
- homepage: http://www.finditparts.com
130
+ homepage: https://github.com/daifu/social_rebate_api_wrapper
131
131
  licenses:
132
132
  - MIT
133
133
  post_install_message: