social_rebate 0.0.5 → 0.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.md +19 -2
- data/lib/social_rebate.rb +11 -5
- data/lib/social_rebate/config.rb +11 -2
- data/lib/social_rebate/version.rb +1 -1
- metadata +1 -1
data/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# SocialRebate
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
This is a gem for social rebate api, it can verify, cancel, and get from social rebate using their api.
|
|
4
4
|
|
|
5
5
|
## Installation
|
|
6
6
|
|
|
@@ -18,7 +18,24 @@ Or install it yourself as:
|
|
|
18
18
|
|
|
19
19
|
## Usage
|
|
20
20
|
|
|
21
|
-
|
|
21
|
+
### Set up
|
|
22
|
+
Set env variable for SR_API_KEY, SR_API_SECRET, and SR_STORE_KEY
|
|
23
|
+
|
|
24
|
+
### Init social rebate
|
|
25
|
+
|
|
26
|
+
```ruby
|
|
27
|
+
SocialRebate.init({:order_email => 'customer@email.com', :total_purchase => '1000', :order_id => 23232})
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
### Verfiy social rebate
|
|
31
|
+
```ruby
|
|
32
|
+
SocialRebate.verify('order token', {:order_email => 'customer@email.com', :total_purchase => '1000', :order_id => 23232})
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
### Cancel social rebate
|
|
36
|
+
```ruby
|
|
37
|
+
SocialRebate.cancel('order token', {:order_email => 'customer@email.com', :total_purchase => '1000', :order_id => 23232})
|
|
38
|
+
```
|
|
22
39
|
|
|
23
40
|
## Contributing
|
|
24
41
|
|
data/lib/social_rebate.rb
CHANGED
|
@@ -8,14 +8,20 @@ require "social_rebate/connection"
|
|
|
8
8
|
module SocialRebate
|
|
9
9
|
|
|
10
10
|
def self.verify(token, option={})
|
|
11
|
-
|
|
12
|
-
option[:status] ||= 'VERIFIED'
|
|
13
|
-
SocialRebate::Connection.new(creds).put("#{sub_base_uri}#{token}/", option)
|
|
11
|
+
set_status(token, option, 'VERIFIED')
|
|
14
12
|
end
|
|
15
13
|
|
|
16
14
|
def self.cancel(token, option={})
|
|
15
|
+
set_status(token, option, 'VOID')
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def self.coupon(token, option={})
|
|
19
|
+
set_status(token, option, "COUPON")
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def self.set_status(token, option, status)
|
|
17
23
|
return unless is_enabled?
|
|
18
|
-
option[:status] ||=
|
|
24
|
+
option[:status] ||= status
|
|
19
25
|
SocialRebate::Connection.new(creds).put("#{sub_base_uri}#{token}/", option)
|
|
20
26
|
end
|
|
21
27
|
|
|
@@ -26,7 +32,7 @@ module SocialRebate
|
|
|
26
32
|
|
|
27
33
|
def self.get(option={}, url='/api/v2/orders/')
|
|
28
34
|
return unless is_enabled?
|
|
29
|
-
SocialRebate::Connection.new(creds).get(url)
|
|
35
|
+
SocialRebate::Connection.new(creds).get(url, option)
|
|
30
36
|
end
|
|
31
37
|
|
|
32
38
|
def self.creds
|
data/lib/social_rebate/config.rb
CHANGED
|
@@ -5,6 +5,7 @@ module SocialRebate
|
|
|
5
5
|
@@api_key = @@api_secret = @@store_key = nil
|
|
6
6
|
@@enabled = true
|
|
7
7
|
@@api_version = 'v2'
|
|
8
|
+
@@offer_type = 'inline_receipt'
|
|
8
9
|
|
|
9
10
|
class << self
|
|
10
11
|
def api_key=(key)
|
|
@@ -19,14 +20,18 @@ module SocialRebate
|
|
|
19
20
|
@@store_key = store_key
|
|
20
21
|
end
|
|
21
22
|
|
|
22
|
-
def api_version=(api_version)
|
|
23
|
-
@@api_version = api_version
|
|
23
|
+
def api_version=(api_version='v2')
|
|
24
|
+
@@api_version = api_version
|
|
24
25
|
end
|
|
25
26
|
|
|
26
27
|
def enabled=(enabled=true)
|
|
27
28
|
@@enabled = enabled
|
|
28
29
|
end
|
|
29
30
|
|
|
31
|
+
def offer_type=(offer_type='inline_receipt')
|
|
32
|
+
@@offer_type = offer_type
|
|
33
|
+
end
|
|
34
|
+
|
|
30
35
|
def api_key
|
|
31
36
|
@@api_key || ENV['SR_API_KEY']
|
|
32
37
|
end
|
|
@@ -50,6 +55,10 @@ module SocialRebate
|
|
|
50
55
|
def api_version
|
|
51
56
|
@@api_version
|
|
52
57
|
end
|
|
58
|
+
|
|
59
|
+
def offer_type
|
|
60
|
+
@@offer_type
|
|
61
|
+
end
|
|
53
62
|
end
|
|
54
63
|
|
|
55
64
|
end
|