t2_airtime 0.1.6 → 0.1.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 930a573c0bbbfd8d401d5516076c722323f4e9ea
4
- data.tar.gz: b127b173d8e7a7a337c6023b05ea3e914fe93bd8
3
+ metadata.gz: 3c44ca5c1ad13b0e761fa655a9686591785a5147
4
+ data.tar.gz: 03fa91213d5f9552f356439b4fb1be1ecd3a9f52
5
5
  SHA512:
6
- metadata.gz: d777c248edff660ae4678c8fc0f93a2051b5a71b65ec78d84bfa61a1ecf7ce27a38478384ab50ef36d396dbfdb66b65e906e1ac1aa01f4e7cbbf8c3ad0859cfb
7
- data.tar.gz: 7509d8f784e189454e4704edd16c24bdd85f5beded68e223ef71faf56fbea68757e92a0f139d67cd986f95952a32c8b1ae5b2de667d6d48d7f0030a13f00c878
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
@@ -0,0 +1,5 @@
1
+ module T2Airtime
2
+ class Engine < ::Rails::Engine
3
+ isolate_namespace T2Airtime
4
+ end
5
+ end
@@ -1,3 +1,3 @@
1
1
  module T2Airtime
2
- VERSION = "0.1.6"
2
+ VERSION = "0.1.7"
3
3
  end
data/lib/t2_airtime.rb CHANGED
@@ -6,6 +6,7 @@ require "countries"
6
6
  require "money"
7
7
 
8
8
  require "t2_airtime/version"
9
+ require "t2_airtime/engine"
9
10
  require "t2_airtime/url"
10
11
  require "t2_airtime/errors"
11
12
  require "t2_airtime/request"
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.6
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