Class: HasOffers::DummyResponse
- Inherits:
-
Object
- Object
- HasOffers::DummyResponse
- Defined in:
- lib/hasoffers/dummy_response.rb
Instance Attribute Summary collapse
-
#body ⇒ Object
Returns the value of attribute body.
-
#code ⇒ Object
Returns the value of attribute code.
-
#headers ⇒ Object
Returns the value of attribute headers.
-
#message ⇒ Object
Returns the value of attribute message.
Class Method Summary collapse
- .response_for(target, method, params) ⇒ Object
- .response_for_advertiser_create(params) ⇒ Object
- .response_for_advertiser_findall(params) ⇒ Object
- .response_for_advertiser_update(params) ⇒ Object
- .response_for_affiliate_create(params) ⇒ Object
- .response_for_affiliate_update(params) ⇒ Object
- .response_for_affiliatebilling_createinvoice(params) ⇒ Object
- .response_for_affiliatebilling_findallinvoices(params) ⇒ Object
- .response_for_affiliatebilling_findallinvoicesbyids(params) ⇒ Object
- .response_for_affiliatebilling_findinvoicestats(params) ⇒ Object
- .response_for_affiliatebilling_updateinvoice(params) ⇒ Object
- .response_for_conversion_create(params) ⇒ Object
- .response_for_conversion_update(params) ⇒ Object
-
.response_for_offer_create(params) ⇒ Object
Assume return_object is set for simplicity which means just the id of offer is returned.
- .response_for_offer_update(params) ⇒ Object
- .response_for_report_getconversions(params) ⇒ Object
- .response_for_report_getstats(params) ⇒ Object
Instance Method Summary collapse
-
#initialize(code, message, body, headers) ⇒ DummyResponse
constructor
A new instance of DummyResponse.
- #to_hash ⇒ Object
Constructor Details
#initialize(code, message, body, headers) ⇒ DummyResponse
Returns a new instance of DummyResponse.
81 82 83 84 85 86 |
# File 'lib/hasoffers/dummy_response.rb', line 81 def initialize(code, , body, headers) @code = code @message = @body = body @headers = headers end |
Instance Attribute Details
#body ⇒ Object
Returns the value of attribute body.
79 80 81 |
# File 'lib/hasoffers/dummy_response.rb', line 79 def body @body end |
#code ⇒ Object
Returns the value of attribute code.
79 80 81 |
# File 'lib/hasoffers/dummy_response.rb', line 79 def code @code end |
#headers ⇒ Object
Returns the value of attribute headers.
79 80 81 |
# File 'lib/hasoffers/dummy_response.rb', line 79 def headers @headers end |
#message ⇒ Object
Returns the value of attribute message.
79 80 81 |
# File 'lib/hasoffers/dummy_response.rb', line 79 def @message end |
Class Method Details
.response_for(target, method, params) ⇒ Object
7 8 9 10 |
# File 'lib/hasoffers/dummy_response.rb', line 7 def response_for(target, method, params) body = self.send("response_for_#{target.downcase}_#{method.downcase}", params) DummyResponse.new(200, 'Ok', body, {}) end |
.response_for_advertiser_create(params) ⇒ Object
41 42 43 |
# File 'lib/hasoffers/dummy_response.rb', line 41 def response_for_advertiser_create(params) {"response" => { "status" => 1, "data" => rand(1_000_000).to_s } } end |
.response_for_advertiser_findall(params) ⇒ Object
37 38 39 |
# File 'lib/hasoffers/dummy_response.rb', line 37 def response_for_advertiser_findall(params) {"response" => { "status" => 1, "data" => {"1" => {"Advertiser" => {"id" => "1", "company" => "Dominoes"}}}, "errors" => {} } } end |
.response_for_advertiser_update(params) ⇒ Object
45 46 47 |
# File 'lib/hasoffers/dummy_response.rb', line 45 def response_for_advertiser_update(params) {"response" => { "status" => 1, "data" => true, "errors" => [] } } end |
.response_for_affiliate_create(params) ⇒ Object
21 22 23 |
# File 'lib/hasoffers/dummy_response.rb', line 21 def response_for_affiliate_create(params) {"response" => { "status" => 1, "data" => rand(1_000_000).to_s } } end |
.response_for_affiliate_update(params) ⇒ Object
25 26 27 |
# File 'lib/hasoffers/dummy_response.rb', line 25 def response_for_affiliate_update(params) {"response" => { "status" => 1, "data" => true, "errors" => [] } } end |
.response_for_affiliatebilling_createinvoice(params) ⇒ Object
29 30 31 |
# File 'lib/hasoffers/dummy_response.rb', line 29 def response_for_affiliatebilling_createinvoice(params) {"response" => { "status" => 1, "data" => rand(1_000_000).to_s } } end |
.response_for_affiliatebilling_findallinvoices(params) ⇒ Object
61 62 63 |
# File 'lib/hasoffers/dummy_response.rb', line 61 def response_for_affiliatebilling_findallinvoices(params) {"response" => { "status" => 1, "data" => {"1" => {"AffiliateInvoice" => {"id" => "1", "affiliate_id" => "2", "datetime" => "2009-06-02 20:14:05", "start_date" => "2009-06-01", "end_date" => "2009-06-02", "is_paid" => "1", "memo" => "asdf", "status" => "active", "notes" => "", "receipt_id" => nil, "currency" => "USD", "amount" => "12.00", "conversions" => "12" }}}, "errors" => []}} end |
.response_for_affiliatebilling_findallinvoicesbyids(params) ⇒ Object
65 66 67 |
# File 'lib/hasoffers/dummy_response.rb', line 65 def response_for_affiliatebilling_findallinvoicesbyids(params) {"response" => { "status" => 1, "data" => {"1" => {"AffiliateInvoice" => {"id" => "1", "affiliate_id" => "2", "datetime" => "2009-06-02 20:14:05", "start_date" => "2009-06-01", "end_date" => "2009-06-02", "is_paid" => "1", "memo" => "asdf", "status" => "active", "notes" => "", "receipt_id" => nil, "currency" => "USD", "amount" => "12.00", "conversions" => "12" }}}, "errors" => []}} end |
.response_for_affiliatebilling_findinvoicestats(params) ⇒ Object
57 58 59 |
# File 'lib/hasoffers/dummy_response.rb', line 57 def response_for_affiliatebilling_findinvoicestats(params) {"response" => { "status" => 1, "data" => {"start_date" => params["start_date"], "end_date" => params["end_date"], "data" => [{"Stat" => {"type" => "stats", "offer_id" => "1", "payout_type" => "cpa_flat", "currency" => "USD", "amount" => "26.00000", "impressions" => "0", "clicks" => "0", "conversions" => "5", "revenue" => "2.50", "sale_amount" => "50.00"}}] }}} end |
.response_for_affiliatebilling_updateinvoice(params) ⇒ Object
33 34 35 |
# File 'lib/hasoffers/dummy_response.rb', line 33 def response_for_affiliatebilling_updateinvoice(params) {"response" => { "status" => 1, "data" => true, "errors" => [] } } end |
.response_for_conversion_create(params) ⇒ Object
49 50 51 |
# File 'lib/hasoffers/dummy_response.rb', line 49 def response_for_conversion_create(params) {"response" => { "status" => 1, "data" => rand(1_000_000).to_s } } end |
.response_for_conversion_update(params) ⇒ Object
53 54 55 |
# File 'lib/hasoffers/dummy_response.rb', line 53 def response_for_conversion_update(params) {"response" => { "status" => 1, "data" => true, "errors" => [] } } end |
.response_for_offer_create(params) ⇒ Object
Assume return_object is set for simplicity which means just the id of offer is returned
13 14 15 |
# File 'lib/hasoffers/dummy_response.rb', line 13 def response_for_offer_create(params) {"response" => { "status" => 1, "data" => rand(1_000_000).to_s } } end |
.response_for_offer_update(params) ⇒ Object
17 18 19 |
# File 'lib/hasoffers/dummy_response.rb', line 17 def response_for_offer_update(params) {"response" => { "status" => 1, "data" => true, "errors" => [] } } end |
.response_for_report_getconversions(params) ⇒ Object
73 74 75 |
# File 'lib/hasoffers/dummy_response.rb', line 73 def response_for_report_getconversions(params) {"response"=>{"data"=>{"pageCount"=>1, "data"=>[{"Stat"=>{"affiliate_id"=>"1", "payout"=>"100.00"}}], "current"=>50, "count"=>1, "page"=>1}, "errors"=>[], "status"=>1}} end |
.response_for_report_getstats(params) ⇒ Object
69 70 71 |
# File 'lib/hasoffers/dummy_response.rb', line 69 def response_for_report_getstats(params) {"response"=>{"data"=>{"pageCount"=>1, "data"=>[{"Stat"=>{"affiliate_id"=>"1", "clicks"=>"20645"}}], "current"=>50, "count"=>1, "page"=>1}, "errors"=>[], "status"=>1}} end |
Instance Method Details
#to_hash ⇒ Object
88 89 90 |
# File 'lib/hasoffers/dummy_response.rb', line 88 def to_hash @headers end |