social_rebate 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # SocialRebate
2
2
 
3
- TODO: Write a gem description
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
- TODO: Write usage instructions here
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
 
@@ -8,14 +8,20 @@ require "social_rebate/connection"
8
8
  module SocialRebate
9
9
 
10
10
  def self.verify(token, option={})
11
- return unless is_enabled?
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] ||= 'VOID'
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
@@ -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 || 'v2'
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
@@ -1,3 +1,3 @@
1
1
  module SocialRebate
2
- VERSION = "0.0.5"
2
+ VERSION = "0.0.6"
3
3
  end
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.5
4
+ version: 0.0.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: