tam 1.0.0 → 1.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/tam/api/charging.rb +36 -0
- data/lib/tam/api/oauth.rb +2 -2
- data/lib/tam/api.rb +1 -0
- data/lib/tam/version.rb +1 -1
- metadata +6 -5
@@ -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
data/lib/tam/version.rb
CHANGED
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:
|
4
|
+
hash: 17
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 1
|
8
|
-
-
|
9
|
-
-
|
10
|
-
version: 1.
|
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-
|
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
|