broke 0.1.1 → 0.1.2

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.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/lib/broke.rb +14 -11
  3. data/lib/broke/token.rb +9 -0
  4. metadata +2 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4d5952063ed7ee816901a359f848d4a7367cf958
4
- data.tar.gz: 95971d9aa1f4cb9341f3a485549daf4dcb023f74
3
+ metadata.gz: d6ccbfb20bd050ea39f8a0ed8bc1bf9d02c7021a
4
+ data.tar.gz: 5f2b1a9c506514423db82d83583098a9606140ad
5
5
  SHA512:
6
- metadata.gz: 3c9ba2b289f7d4b0a1fced74e1e2dbc0455c4c263f0ba56e90dd0e4c66e525066ce1b68cd255b53731d174227ff30dc11b1a0152998627bd657177c16a544b0f
7
- data.tar.gz: 39d3509f0586c1d1279adf0189dbdebe1e3425a4fc5e45f380d9771f872ccccfeccb984ef781af461d83218837dc540128d38cbe5adf9996e349f4a914f12a91
6
+ metadata.gz: 558a208ef2edb748b88fe17d9e323767d2f3093671ffe8e910daf97a3ed397ef9b017eec2e790b062f822b0d0e5d15d35180eeccb141e1f18b00900f91b6602c
7
+ data.tar.gz: 3182a9f06d3f0966126048dad7f6c7157f4773795619039ff81bde68c774376dbf447f4a8569c388b6ff4ea776ecd81f44d624776c838a38f30917ffc42ee1b9
@@ -3,17 +3,19 @@ require 'faraday_middleware'
3
3
 
4
4
  class Broke
5
5
 
6
- class << self
7
- attr_accessor :api_key
6
+ def initialize keys = {}
7
+ @@public_key = keys[:public_key]
8
+ @@private_key = keys[:private_key]
8
9
  end
9
10
 
10
- def initialize api_key
11
- @@api_key = api_key
12
- @@conn = Faraday.new(:url => 'https://api.paymentwall.com/api') do |conn|
13
- conn.request :url_encoded
14
- conn.response :json, :content_type => 'application/json'
15
- conn.adapter Faraday.default_adapter
16
- end
11
+ @@conn = Faraday.new(:url => 'https://api.paymentwall.com/api') do |conn|
12
+ conn.request :url_encoded
13
+ conn.response :json, :content_type => 'application/json'
14
+ conn.adapter Faraday.default_adapter
15
+ end
16
+
17
+ def token
18
+ Token.new
17
19
  end
18
20
 
19
21
  def charge
@@ -32,20 +34,21 @@ class Broke
32
34
 
33
35
  def get path
34
36
  @@conn.get do |req|
35
- req.headers['X-ApiKey'] = @@api_key
37
+ req.headers['X-ApiKey'] = @@private_key
36
38
  req.url path
37
39
  end
38
40
  end
39
41
 
40
42
  def post path, params
41
43
  @@conn.post do |req|
42
- req.headers['X-ApiKey'] = @@api_key
44
+ req.headers['X-ApiKey'] = @@private_key
43
45
  req.url path
44
46
  req.body = params
45
47
  end
46
48
  end
47
49
  end
48
50
 
51
+ require 'broke/token'
49
52
  require 'broke/subscription'
50
53
  require 'broke/charge'
51
54
  require 'broke/pingback'
@@ -0,0 +1,9 @@
1
+ class Broke::Token < Broke
2
+
3
+ def initialize; end
4
+
5
+ def create params
6
+ params[:public_key] = @@public_key
7
+ post 'brick/token', params
8
+ end
9
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: broke
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Youssef Kababe
@@ -48,6 +48,7 @@ files:
48
48
  - lib/broke/charge.rb
49
49
  - lib/broke/pingback.rb
50
50
  - lib/broke/subscription.rb
51
+ - lib/broke/token.rb
51
52
  homepage: https://github.com/YoussefKababe/broke
52
53
  licenses:
53
54
  - MIT