Class: T2Airtime::AirtimeController
- Inherits:
-
ActionController::API
- Object
- ActionController::API
- T2Airtime::AirtimeController
- Defined in:
- app/controllers/t2_airtime/airtime_controller.rb
Instance Method Summary collapse
- #countries ⇒ Object
- #operators ⇒ Object
- #products ⇒ Object
- #transaction ⇒ Object
- #transactions ⇒ Object
Instance Method Details
#countries ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 |
# File 'app/controllers/t2_airtime/airtime_controller.rb', line 4 def countries reply = T2Airtime::API.api.country_list if reply.success? data = T2Airtime::Country.serialize(reply.data) render json: { countries: data, status: :ok } else render_error(T2Airtime::Error.new(reply.error_code, reply.)) end end |
#operators ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'app/controllers/t2_airtime/airtime_controller.rb', line 17 def operators reply = T2Airtime::API.api.operator_list(params[:country_aid]) if reply.success? data = T2Airtime::Operator.serialize(reply.data) render json: { operators: data, status: :ok } else render_error(T2Airtime::Error.new(reply.error_code, reply.)) end end |
#products ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'app/controllers/t2_airtime/airtime_controller.rb', line 30 def products reply = T2Airtime::API.api.product_list(params[:operator_aid]) if reply.success? data = T2Airtime::Product.serialize(reply.data) render json: { products: data, status: :ok } else render_error(T2Airtime::Error.new(reply.error_code, reply.)) end end |
#transaction ⇒ Object
56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'app/controllers/t2_airtime/airtime_controller.rb', line 56 def transaction reply = T2Airtime::API.api.trans_info(params[:id]) if reply.success? data = T2Airtime::Transaction.serialize_one(reply.data) render json: { transaction: data, status: :ok } else render_error(T2Airtime::Error.new(reply.error_code, reply.)) end end |
#transactions ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'app/controllers/t2_airtime/airtime_controller.rb', line 43 def transactions reply = T2Airtime::API.api.trans_list(params[:start], params[:stop], params[:msisdn], params[:destination], params[:code]) if reply.success? data = T2Airtime::Transaction.serialize(reply.data) render json: { transactions: data, status: :ok } else render_error(T2Airtime::Error.new(reply.error_code, reply.)) end end |