tam 1.0.0 → 1.1.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,36 @@
1
+ require 'json'
2
+ require 'tam/user'
3
+ require 'tam/error'
4
+
5
+ # Charging part of the telco asset marketplace REST API
6
+ module TAM
7
+ class API
8
+ # Requests for charging or payment to the subscriber account in the operator billing system by amount.
9
+ #
10
+ # @return [Hash]
11
+ # {"status"=>{"code"=>0, "message"=>"Request was handled succesfully"}}
12
+ def self.charge_by_amount(user, amount)
13
+ begin
14
+ payload = JSON.generate({'method' => 'AMOUNT', 'amount' => amount.to_s})
15
+ response = dispatch_to_tam(:post, '/api/1/charge/request', user, payload)
16
+ JSON.parse response
17
+ rescue TAM::ServiceUnavailable
18
+ raise TAM::ServiceUnavailable.new 'The charging service is not available. If you are using the service on a persona, i.e.: through the sandbox, then remember to set the balance of that persona'
19
+ end
20
+ end
21
+
22
+ # Requests for charging or payment to the subscriber account in the operator billing system byt charging code.
23
+ #
24
+ # @return [Hash]
25
+ # {"status"=>{"code"=>0, "message"=>"Request was handled succesfully"}}
26
+ def self.charge_by_code(user, code)
27
+ begin
28
+ payload = JSON.generate({'method' => 'CODE', 'charging_code' => code.to_s})
29
+ response = dispatch_to_tam(:post, '/api/1/charge/request', user, payload)
30
+ JSON.parse response
31
+ rescue TAM::ServiceUnavailable
32
+ raise TAM::ServiceUnavailable.new 'The charging service is not available. If you are using the service on a persona, i.e.: through the sandbox, then remember to set the balance of that persona'
33
+ end
34
+ end
35
+ end
36
+ end
data/lib/tam/api/oauth.rb CHANGED
@@ -29,9 +29,9 @@ module TAM
29
29
  verifier = params[:oauth_verifier]
30
30
  access_token = request_token.get_access_token(:oauth_verifier => verifier)
31
31
  user = User.new(access_token.token, access_token.secret)
32
- redirect dispatch_to_handler('authorized', user, session)
32
+ redirect url(dispatch_to_handler('authorized', user, session))
33
33
  else
34
- redirect dispatch_to_handler('denied', session)
34
+ redirect url(dispatch_to_handler('denied', session))
35
35
  end
36
36
  end
37
37
 
data/lib/tam/api.rb CHANGED
@@ -15,6 +15,7 @@ module TAM
15
15
  require 'tam/api/oauth'
16
16
  require 'tam/api/sms'
17
17
  require 'tam/api/location'
18
+ require 'tam/api/charging'
18
19
 
19
20
  # Dispatches the request to the telco asset marketplace handler configured by
20
21
  # this gem client
data/lib/tam/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  module TAM
2
2
  # The version of the gem
3
- VERSION = '1.0.0'.freeze unless defined?(::TAM::VERSION)
3
+ VERSION = '1.1.1'.freeze unless defined?(::TAM::VERSION)
4
4
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tam
3
3
  version: !ruby/object:Gem::Version
4
- hash: 23
4
+ hash: 17
5
5
  prerelease: false
6
6
  segments:
7
7
  - 1
8
- - 0
9
- - 0
10
- version: 1.0.0
8
+ - 1
9
+ - 1
10
+ version: 1.1.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Carlos Manzanares
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-06-06 00:00:00 +03:00
18
+ date: 2011-06-08 00:00:00 +03:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -82,6 +82,7 @@ files:
82
82
  - Rakefile
83
83
  - lib/tam.rb
84
84
  - lib/tam/api.rb
85
+ - lib/tam/api/charging.rb
85
86
  - lib/tam/api/location.rb
86
87
  - lib/tam/api/oauth.rb
87
88
  - lib/tam/api/sms.rb