t2_airtime 0.1.6 → 0.1.7
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.
- checksums.yaml +4 -4
- data/app/controllers/t2_airtime/airtime_controller.rb +81 -0
- data/config/routes.rb +8 -0
- data/lib/t2_airtime/engine.rb +5 -0
- data/lib/t2_airtime/version.rb +1 -1
- data/lib/t2_airtime.rb +1 -0
- metadata +4 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3c44ca5c1ad13b0e761fa655a9686591785a5147
|
4
|
+
data.tar.gz: 03fa91213d5f9552f356439b4fb1be1ecd3a9f52
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 415896424a99f1b0bddaf6be3cf16f8675b3bdd5547f78712cc63fdfd0983bd633cec09ac7baa951f1103197d71c071130f1ed22ae3341c8274f447e7773d216
|
7
|
+
data.tar.gz: 3dabeaa26a0af936aa9613ff5c691ba8aadbfdc68151abc01200f96de70bb856d2851a5c69cd14d296a99f307be9710f550e599a24afa8ba0976e82c2b0793b9
|
@@ -0,0 +1,81 @@
|
|
1
|
+
module T2Airtime
|
2
|
+
class AirtimeController < ActionController::API
|
3
|
+
|
4
|
+
def countries
|
5
|
+
reply = T2Airtime::API.api.country_list
|
6
|
+
if reply.success?
|
7
|
+
data = T2Airtime::Country.serialize(reply.data)
|
8
|
+
render json: {
|
9
|
+
countries: data,
|
10
|
+
status: :ok
|
11
|
+
}
|
12
|
+
else
|
13
|
+
render_error(T2Airtime::Error.new(reply.error_code, reply.error_message))
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def operators
|
18
|
+
reply = T2Airtime::API.api.operator_list(params[:country_aid])
|
19
|
+
if reply.success?
|
20
|
+
data = T2Airtime::Operator.serialize(reply.data)
|
21
|
+
render json: {
|
22
|
+
operators: data,
|
23
|
+
status: :ok
|
24
|
+
}
|
25
|
+
else
|
26
|
+
render_error(T2Airtime::Error.new(reply.error_code, reply.error_message))
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def products
|
31
|
+
reply = T2Airtime::API.api.product_list(params[:operator_aid])
|
32
|
+
if reply.success?
|
33
|
+
data = T2Airtime::Product.serialize(reply.data)
|
34
|
+
render json: {
|
35
|
+
products: data,
|
36
|
+
status: :ok
|
37
|
+
}
|
38
|
+
else
|
39
|
+
render_error(T2Airtime::Error.new(reply.error_code, reply.error_message))
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def transactions
|
44
|
+
reply = T2Airtime::API.api.trans_list(params[:start], params[:stop], params[:msisdn], params[:destination], params[:code])
|
45
|
+
if reply.success?
|
46
|
+
data = T2Airtime::Transaction.serialize(reply.data)
|
47
|
+
render json: {
|
48
|
+
transactions: data,
|
49
|
+
status: :ok
|
50
|
+
}
|
51
|
+
else
|
52
|
+
render_error(T2Airtime::Error.new(reply.error_code, reply.error_message))
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def transaction
|
57
|
+
reply = T2Airtime::API.api.trans_info(params[:id])
|
58
|
+
if reply.success?
|
59
|
+
data = T2Airtime::Transaction.serialize_one(reply.data)
|
60
|
+
render json: {
|
61
|
+
transaction: data,
|
62
|
+
status: :ok
|
63
|
+
}
|
64
|
+
else
|
65
|
+
render_error(T2Airtime::Error.new(reply.error_code, reply.error_message))
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
protected
|
70
|
+
|
71
|
+
def render_error(error)
|
72
|
+
render json: {
|
73
|
+
code: error.code,
|
74
|
+
message: error.message,
|
75
|
+
status: :bad_request
|
76
|
+
}
|
77
|
+
end
|
78
|
+
|
79
|
+
|
80
|
+
end
|
81
|
+
end
|
data/config/routes.rb
ADDED
@@ -0,0 +1,8 @@
|
|
1
|
+
|
2
|
+
T2Airtime::Engine.application.routes.draw do
|
3
|
+
get '/countries', to: 'airtime#countries'
|
4
|
+
get '/:country_aid/operators', to: 'airtime#operators'
|
5
|
+
get '/:operator_aid/products', to: 'airtime#products'
|
6
|
+
get '/transactions', to: 'airtime#transactions'
|
7
|
+
get '/transactions/:id', to: 'airtime#transaction'
|
8
|
+
end
|
data/lib/t2_airtime/version.rb
CHANGED
data/lib/t2_airtime.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: t2_airtime
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- matteolc
|
@@ -130,9 +130,12 @@ files:
|
|
130
130
|
- LICENSE.txt
|
131
131
|
- README.md
|
132
132
|
- Rakefile
|
133
|
+
- app/controllers/t2_airtime/airtime_controller.rb
|
134
|
+
- config/routes.rb
|
133
135
|
- lib/t2_airtime.rb
|
134
136
|
- lib/t2_airtime/api.rb
|
135
137
|
- lib/t2_airtime/base.rb
|
138
|
+
- lib/t2_airtime/engine.rb
|
136
139
|
- lib/t2_airtime/errors.rb
|
137
140
|
- lib/t2_airtime/reply.rb
|
138
141
|
- lib/t2_airtime/request.rb
|