Class: StreetCred::Handler
- Inherits:
-
Object
- Object
- StreetCred::Handler
- Defined in:
- lib/streetcred.rb
Instance Method Summary collapse
-
#handle(params) ⇒ Object
handles a hash of params, and responds with response hash.
-
#initialize(app_id, app_secret) ⇒ Handler
constructor
A new instance of Handler.
Constructor Details
#initialize(app_id, app_secret) ⇒ Handler
Returns a new instance of Handler.
8 9 10 11 |
# File 'lib/streetcred.rb', line 8 def initialize(app_id, app_secret) @app_id = app_id @app_secret = app_secret end |
Instance Method Details
#handle(params) ⇒ Object
handles a hash of params, and responds with response hash
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/streetcred.rb', line 14 def handle(params) validate_signed_request(params[:signed_request]) if params[:order_details] order_details = ActiveSupport::JSON.decode(params[:order_details]) response = { 'content' => { 'order_id' => order_details['order_id'], 'status' => 'settled' }, 'method' => 'payments_status_update' } else product_info = { 'method' => 'pay', 'title' => 'My Awsome Virtual Item', 'description' => 'Best. Virtual Item. Ever.', 'image_url' => "http://2.bp.blogspot.com/-nqAn1B4aRxo/TxNmL93PoAI/AAAAAAAACvU/t0N5_6r7ds8/s1600/pid1534-dog_bowl_hi_res.jpg", 'product_url' => 'google.com/dogs', 'price' => 1, 'item_id' => 'MY_ITEM_ID' } response = { 'content' => [product_info], 'method' => 'payments_get_items' } end response end |