oi-api-ruby 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (180) hide show
  1. checksums.yaml +7 -0
  2. data/.env.sample +2 -0
  3. data/.gitignore +3 -0
  4. data/.rspec +4 -0
  5. data/.ruby-version +1 -0
  6. data/Gemfile +4 -0
  7. data/LICENSE.txt +22 -0
  8. data/README.md +35 -0
  9. data/Rakefile +9 -0
  10. data/api_issues.md +89 -0
  11. data/lib/oi_api.rb +12 -0
  12. data/lib/oi_api/client.rb +98 -0
  13. data/lib/oi_api/client/advertisers.rb +31 -0
  14. data/lib/oi_api/client/auto_responders.rb +35 -0
  15. data/lib/oi_api/client/balances.rb +15 -0
  16. data/lib/oi_api/client/cards.rb +33 -0
  17. data/lib/oi_api/client/charges.rb +15 -0
  18. data/lib/oi_api/client/data_transfers.rb +31 -0
  19. data/lib/oi_api/client/offers.rb +32 -0
  20. data/lib/oi_api/client/reports.rb +15 -0
  21. data/lib/oi_api/client/subscriptions.rb +23 -0
  22. data/lib/oi_api/configuration.rb +50 -0
  23. data/lib/oi_api/lookup_tables.rb +42 -0
  24. data/lib/oi_api/version.rb +3 -0
  25. data/oi-api-ruby.gemspec +31 -0
  26. data/spec/cassettes/OiApi_Client_Advertisers/_advertiser/it_should_behave_like_GET_resource/returns_200_OK.yml +157 -0
  27. data/spec/cassettes/OiApi_Client_Advertisers/_advertiser/it_should_behave_like_GET_resource/returns_HTTParty_Response.yml +157 -0
  28. data/spec/cassettes/OiApi_Client_Advertisers/_advertiser/it_should_behave_like_GET_resource/returns_the_resource.yml +157 -0
  29. data/spec/cassettes/OiApi_Client_Advertisers/_advertiser/it_should_behave_like_GET_resource/when_advertiser_id_not_found/returns_404.yml +77 -0
  30. data/spec/cassettes/OiApi_Client_Advertisers/_advertiser/it_should_behave_like_GET_resource/when_advertiser_id_not_found/returns_not_found_error_message.yml +117 -0
  31. data/spec/cassettes/OiApi_Client_Advertisers/_advertisers/it_should_behave_like_GET_resources/returns_200_OK.yml +157 -0
  32. data/spec/cassettes/OiApi_Client_Advertisers/_advertisers/it_should_behave_like_GET_resources/returns_HTTParty_Response.yml +237 -0
  33. data/spec/cassettes/OiApi_Client_Advertisers/_advertisers/it_should_behave_like_GET_resources/returns_all_resources.yml +237 -0
  34. data/spec/cassettes/OiApi_Client_Advertisers/_create_advertiser/it_should_behave_like_POST_resource/bad_request/returns_400_bad_request_with_invalid_params.yml +117 -0
  35. data/spec/cassettes/OiApi_Client_Advertisers/_create_advertiser/it_should_behave_like_POST_resource/bad_request/returns_an_error_message.yml +77 -0
  36. data/spec/cassettes/OiApi_Client_Advertisers/_create_advertiser/it_should_behave_like_POST_resource/bad_request/returns_an_error_status.yml +77 -0
  37. data/spec/cassettes/OiApi_Client_Advertisers/_create_advertiser/it_should_behave_like_POST_resource/returns_201_created.yml +118 -0
  38. data/spec/cassettes/OiApi_Client_Advertisers/_create_advertiser/it_should_behave_like_POST_resource/returns_a_success_message.yml +78 -0
  39. data/spec/cassettes/OiApi_Client_Advertisers/_create_advertiser/it_should_behave_like_POST_resource/returns_a_success_status.yml +118 -0
  40. data/spec/cassettes/OiApi_Client_Advertisers/_delete_advertiser/it_should_behave_like_DELETE_resource/deletes_a_data_transfer.yml +153 -0
  41. data/spec/cassettes/OiApi_Client_Advertisers/_delete_advertiser/it_should_behave_like_DELETE_resource/returns_200_OK.yml +116 -0
  42. data/spec/cassettes/OiApi_Client_Advertisers/_delete_advertiser/it_should_behave_like_DELETE_resource/returns_the_correct_message.yml +196 -0
  43. data/spec/cassettes/OiApi_Client_Advertisers/_delete_advertiser/it_should_behave_like_DELETE_resource/returns_the_correct_status.yml +116 -0
  44. data/spec/cassettes/OiApi_Client_Advertisers/_delete_advertiser/it_should_behave_like_DELETE_resource/when_advertiser_not_found/returns_404.yml +77 -0
  45. data/spec/cassettes/OiApi_Client_Advertisers/_delete_advertiser/it_should_behave_like_DELETE_resource/when_advertiser_not_found/returns_not_found_error_message.yml +77 -0
  46. data/spec/cassettes/OiApi_Client_Advertisers/_delete_advertiser/it_should_behave_like_DELETE_resource/when_advertiser_not_found/returns_not_found_error_status.yml +77 -0
  47. data/spec/cassettes/OiApi_Client_Advertisers/_reports/it_should_behave_like_GET_resources/returns_200_OK.yml +42 -0
  48. data/spec/cassettes/OiApi_Client_Advertisers/_reports/it_should_behave_like_GET_resources/returns_HTTParty_Response.yml +42 -0
  49. data/spec/cassettes/OiApi_Client_Advertisers/_reports/it_should_behave_like_GET_resources/returns_all_resources.yml +42 -0
  50. data/spec/cassettes/OiApi_Client_Advertisers/_update_advertiser/it_should_behave_like_PUT_resource/bad_request/returns_400_bad_request_with_invalid_params.yml +116 -0
  51. data/spec/cassettes/OiApi_Client_Advertisers/_update_advertiser/it_should_behave_like_PUT_resource/bad_request/returns_an_error_message.yml +156 -0
  52. data/spec/cassettes/OiApi_Client_Advertisers/_update_advertiser/it_should_behave_like_PUT_resource/bad_request/returns_an_error_status.yml +156 -0
  53. data/spec/cassettes/OiApi_Client_Advertisers/_update_advertiser/it_should_behave_like_PUT_resource/returns_200_OK.yml +155 -0
  54. data/spec/cassettes/OiApi_Client_Advertisers/_update_advertiser/it_should_behave_like_PUT_resource/returns_the_correct_message.yml +155 -0
  55. data/spec/cassettes/OiApi_Client_Advertisers/_update_advertiser/it_should_behave_like_PUT_resource/returns_the_correct_status.yml +195 -0
  56. data/spec/cassettes/OiApi_Client_Advertisers/_update_advertiser/it_should_behave_like_PUT_resource/when_advertiser_not_found/returns_404.yml +117 -0
  57. data/spec/cassettes/OiApi_Client_Advertisers/_update_advertiser/it_should_behave_like_PUT_resource/when_advertiser_not_found/returns_error_status.yml +77 -0
  58. data/spec/cassettes/OiApi_Client_Advertisers/_update_advertiser/it_should_behave_like_PUT_resource/when_advertiser_not_found/returns_not_found_error_message.yml +77 -0
  59. data/spec/cassettes/OiApi_Client_AutoResponders/_all_auto_responders/it_should_behave_like_GET_resources/returns_200_OK.yml +593 -0
  60. data/spec/cassettes/OiApi_Client_AutoResponders/_all_auto_responders/it_should_behave_like_GET_resources/returns_HTTParty_Response.yml +593 -0
  61. data/spec/cassettes/OiApi_Client_AutoResponders/_all_auto_responders/it_should_behave_like_GET_resources/returns_all_resources.yml +593 -0
  62. data/spec/cassettes/OiApi_Client_AutoResponders/_auto_responders/it_should_behave_like_GET_resources/returns_200_OK.yml +273 -0
  63. data/spec/cassettes/OiApi_Client_AutoResponders/_auto_responders/it_should_behave_like_GET_resources/returns_HTTParty_Response.yml +273 -0
  64. data/spec/cassettes/OiApi_Client_AutoResponders/_auto_responders/it_should_behave_like_GET_resources/returns_all_resources.yml +273 -0
  65. data/spec/cassettes/OiApi_Client_AutoResponders/_auto_responders_no_offer_id/it_should_behave_like_GET_resources/returns_200_OK.yml +593 -0
  66. data/spec/cassettes/OiApi_Client_AutoResponders/_auto_responders_no_offer_id/it_should_behave_like_GET_resources/returns_HTTParty_Response.yml +673 -0
  67. data/spec/cassettes/OiApi_Client_AutoResponders/_auto_responders_no_offer_id/it_should_behave_like_GET_resources/returns_all_resources.yml +516 -0
  68. data/spec/cassettes/OiApi_Client_AutoResponders/_auto_responders_with_offer_id/it_should_behave_like_GET_resources/returns_200_OK.yml +273 -0
  69. data/spec/cassettes/OiApi_Client_AutoResponders/_auto_responders_with_offer_id/it_should_behave_like_GET_resources/returns_HTTParty_Response.yml +354 -0
  70. data/spec/cassettes/OiApi_Client_AutoResponders/_auto_responders_with_offer_id/it_should_behave_like_GET_resources/returns_all_resources.yml +354 -0
  71. data/spec/cassettes/OiApi_Client_Balances/_balance/it_should_behave_like_GET_resources/returns_200_OK.yml +78 -0
  72. data/spec/cassettes/OiApi_Client_Balances/_balance/it_should_behave_like_GET_resources/returns_HTTParty_Response.yml +78 -0
  73. data/spec/cassettes/OiApi_Client_Balances/_balance/it_should_behave_like_GET_resources/returns_all_resources.yml +78 -0
  74. data/spec/cassettes/OiApi_Client_Balances/_balance/returns_a_balance.yml +78 -0
  75. data/spec/cassettes/OiApi_Client_Cards/_card/it_should_behave_like_GET_resource/returns_200_OK.yml +117 -0
  76. data/spec/cassettes/OiApi_Client_Cards/_card/it_should_behave_like_GET_resource/returns_HTTParty_Response.yml +117 -0
  77. data/spec/cassettes/OiApi_Client_Cards/_card/it_should_behave_like_GET_resource/returns_the_resource.yml +117 -0
  78. data/spec/cassettes/OiApi_Client_Cards/_card/it_should_behave_like_GET_resource/when_card_id_not_found/returns_404.yml +79 -0
  79. data/spec/cassettes/OiApi_Client_Cards/_card/it_should_behave_like_GET_resource/when_card_id_not_found/returns_not_found_error_message.yml +79 -0
  80. data/spec/cassettes/OiApi_Client_Cards/_create_card/it_should_behave_like_POST_resource/bad_request/returns_400_bad_request_with_invalid_params.yml +80 -0
  81. data/spec/cassettes/OiApi_Client_Cards/_create_card/it_should_behave_like_POST_resource/bad_request/returns_an_error_message.yml +80 -0
  82. data/spec/cassettes/OiApi_Client_Cards/_create_card/it_should_behave_like_POST_resource/bad_request/returns_an_error_status.yml +80 -0
  83. data/spec/cassettes/OiApi_Client_Cards/_create_card/it_should_behave_like_POST_resource/returns_201_created.yml +80 -0
  84. data/spec/cassettes/OiApi_Client_Cards/_create_card/it_should_behave_like_POST_resource/returns_a_success_message.yml +80 -0
  85. data/spec/cassettes/OiApi_Client_Cards/_create_card/it_should_behave_like_POST_resource/returns_a_success_status.yml +80 -0
  86. data/spec/cassettes/OiApi_Client_Cards/_update_card/it_should_behave_like_PUT_resource/bad_request/returns_400_bad_request_with_invalid_params.yml +117 -0
  87. data/spec/cassettes/OiApi_Client_Cards/_update_card/it_should_behave_like_PUT_resource/bad_request/returns_an_error_message.yml +117 -0
  88. data/spec/cassettes/OiApi_Client_Cards/_update_card/it_should_behave_like_PUT_resource/bad_request/returns_an_error_status.yml +117 -0
  89. data/spec/cassettes/OiApi_Client_Cards/_update_card/it_should_behave_like_PUT_resource/returns_200_OK.yml +117 -0
  90. data/spec/cassettes/OiApi_Client_Cards/_update_card/it_should_behave_like_PUT_resource/returns_the_correct_message.yml +117 -0
  91. data/spec/cassettes/OiApi_Client_Cards/_update_card/it_should_behave_like_PUT_resource/returns_the_correct_status.yml +117 -0
  92. data/spec/cassettes/OiApi_Client_Cards/_update_card/it_should_behave_like_PUT_resource/when_card_not_found/returns_404.yml +79 -0
  93. data/spec/cassettes/OiApi_Client_Cards/_update_card/it_should_behave_like_PUT_resource/when_card_not_found/returns_error_status.yml +79 -0
  94. data/spec/cassettes/OiApi_Client_Cards/_update_card/it_should_behave_like_PUT_resource/when_card_not_found/returns_not_found_error_message.yml +79 -0
  95. data/spec/cassettes/OiApi_Client_DataTransfers/_create_data_transfer/it_should_behave_like_POST_resource/bad_request/returns_400_bad_request_with_invalid_params.yml +352 -0
  96. data/spec/cassettes/OiApi_Client_DataTransfers/_create_data_transfer/it_should_behave_like_POST_resource/bad_request/returns_an_error_message.yml +352 -0
  97. data/spec/cassettes/OiApi_Client_DataTransfers/_create_data_transfer/it_should_behave_like_POST_resource/bad_request/returns_an_error_status.yml +352 -0
  98. data/spec/cassettes/OiApi_Client_DataTransfers/_create_data_transfer/it_should_behave_like_POST_resource/returns_201_created.yml +352 -0
  99. data/spec/cassettes/OiApi_Client_DataTransfers/_create_data_transfer/it_should_behave_like_POST_resource/returns_a_success_message.yml +272 -0
  100. data/spec/cassettes/OiApi_Client_DataTransfers/_create_data_transfer/it_should_behave_like_POST_resource/returns_a_success_status.yml +352 -0
  101. data/spec/cassettes/OiApi_Client_DataTransfers/_data_transfer/it_should_behave_like_GET_resource/returns_200_OK.yml +393 -0
  102. data/spec/cassettes/OiApi_Client_DataTransfers/_data_transfer/it_should_behave_like_GET_resource/returns_HTTParty_Response.yml +393 -0
  103. data/spec/cassettes/OiApi_Client_DataTransfers/_data_transfer/it_should_behave_like_GET_resource/returns_the_resource.yml +472 -0
  104. data/spec/cassettes/OiApi_Client_DataTransfers/_data_transfer/it_should_behave_like_GET_resource/when_data_transfer_id_not_found/returns_404.yml +115 -0
  105. data/spec/cassettes/OiApi_Client_DataTransfers/_data_transfer/it_should_behave_like_GET_resource/when_data_transfer_id_not_found/returns_not_found_error_message.yml +236 -0
  106. data/spec/cassettes/OiApi_Client_DataTransfers/_data_transfers/it_should_behave_like_GET_resources/returns_200_OK.yml +354 -0
  107. data/spec/cassettes/OiApi_Client_DataTransfers/_data_transfers/it_should_behave_like_GET_resources/returns_HTTParty_Response.yml +434 -0
  108. data/spec/cassettes/OiApi_Client_DataTransfers/_data_transfers/it_should_behave_like_GET_resources/returns_all_resources.yml +434 -0
  109. data/spec/cassettes/OiApi_Client_DataTransfers/_delete_data_transfer/it_should_behave_like_DELETE_resource/deletes_a_data_transfer.yml +428 -0
  110. data/spec/cassettes/OiApi_Client_DataTransfers/_delete_data_transfer/it_should_behave_like_DELETE_resource/returns_200_OK.yml +390 -0
  111. data/spec/cassettes/OiApi_Client_DataTransfers/_delete_data_transfer/it_should_behave_like_DELETE_resource/returns_the_correct_message.yml +310 -0
  112. data/spec/cassettes/OiApi_Client_DataTransfers/_delete_data_transfer/it_should_behave_like_DELETE_resource/returns_the_correct_status.yml +390 -0
  113. data/spec/cassettes/OiApi_Client_DataTransfers/_delete_data_transfer/it_should_behave_like_DELETE_resource/when_data_transfer_not_found/returns_404.yml +115 -0
  114. data/spec/cassettes/OiApi_Client_DataTransfers/_delete_data_transfer/it_should_behave_like_DELETE_resource/when_data_transfer_not_found/returns_not_found_error_message.yml +195 -0
  115. data/spec/cassettes/OiApi_Client_DataTransfers/_delete_data_transfer/it_should_behave_like_DELETE_resource/when_data_transfer_not_found/returns_not_found_error_status.yml +115 -0
  116. data/spec/cassettes/OiApi_Client_DataTransfers/_update_data_transfer/it_should_behave_like_PUT_resource/bad_request/returns_400_bad_request_with_invalid_params.yml +390 -0
  117. data/spec/cassettes/OiApi_Client_DataTransfers/_update_data_transfer/it_should_behave_like_PUT_resource/bad_request/returns_an_error_message.yml +390 -0
  118. data/spec/cassettes/OiApi_Client_DataTransfers/_update_data_transfer/it_should_behave_like_PUT_resource/bad_request/returns_an_error_status.yml +390 -0
  119. data/spec/cassettes/OiApi_Client_DataTransfers/_update_data_transfer/it_should_behave_like_PUT_resource/returns_200_OK.yml +389 -0
  120. data/spec/cassettes/OiApi_Client_DataTransfers/_update_data_transfer/it_should_behave_like_PUT_resource/returns_the_correct_message.yml +389 -0
  121. data/spec/cassettes/OiApi_Client_DataTransfers/_update_data_transfer/it_should_behave_like_PUT_resource/returns_the_correct_status.yml +349 -0
  122. data/spec/cassettes/OiApi_Client_DataTransfers/_update_data_transfer/it_should_behave_like_PUT_resource/when_data_transfer_not_found/returns_404.yml +274 -0
  123. data/spec/cassettes/OiApi_Client_DataTransfers/_update_data_transfer/it_should_behave_like_PUT_resource/when_data_transfer_not_found/returns_error_status.yml +234 -0
  124. data/spec/cassettes/OiApi_Client_DataTransfers/_update_data_transfer/it_should_behave_like_PUT_resource/when_data_transfer_not_found/returns_not_found_error_message.yml +234 -0
  125. data/spec/cassettes/OiApi_Client_Offers/_create_offer/it_should_behave_like_POST_resource/bad_request/returns_400_bad_request_with_invalid_params.yml +195 -0
  126. data/spec/cassettes/OiApi_Client_Offers/_create_offer/it_should_behave_like_POST_resource/bad_request/returns_an_error_message.yml +195 -0
  127. data/spec/cassettes/OiApi_Client_Offers/_create_offer/it_should_behave_like_POST_resource/bad_request/returns_an_error_status.yml +195 -0
  128. data/spec/cassettes/OiApi_Client_Offers/_create_offer/it_should_behave_like_POST_resource/returns_201_created.yml +196 -0
  129. data/spec/cassettes/OiApi_Client_Offers/_create_offer/it_should_behave_like_POST_resource/returns_a_success_message.yml +156 -0
  130. data/spec/cassettes/OiApi_Client_Offers/_create_offer/it_should_behave_like_POST_resource/returns_a_success_status.yml +196 -0
  131. data/spec/cassettes/OiApi_Client_Offers/_offer/it_should_behave_like_GET_resource/returns_200_OK.yml +246 -0
  132. data/spec/cassettes/OiApi_Client_Offers/_offer/it_should_behave_like_GET_resource/returns_HTTParty_Response.yml +246 -0
  133. data/spec/cassettes/OiApi_Client_Offers/_offer/it_should_behave_like_GET_resource/returns_the_resource.yml +284 -0
  134. data/spec/cassettes/OiApi_Client_Offers/_offer/it_should_behave_like_GET_resource/when_offer_id_not_found/returns_404.yml +115 -0
  135. data/spec/cassettes/OiApi_Client_Offers/_offer/it_should_behave_like_GET_resource/when_offer_id_not_found/returns_not_found_error_message.yml +195 -0
  136. data/spec/cassettes/OiApi_Client_Offers/_offers/it_should_behave_like_GET_resources/returns_200_OK.yml +416 -0
  137. data/spec/cassettes/OiApi_Client_Offers/_offers/it_should_behave_like_GET_resources/returns_HTTParty_Response.yml +457 -0
  138. data/spec/cassettes/OiApi_Client_Offers/_offers/it_should_behave_like_GET_resources/returns_all_resources.yml +457 -0
  139. data/spec/cassettes/OiApi_Client_Offers/_update_offer/it_should_behave_like_PUT_resource/bad_request/returns_400_bad_request_with_invalid_params.yml +194 -0
  140. data/spec/cassettes/OiApi_Client_Offers/_update_offer/it_should_behave_like_PUT_resource/bad_request/returns_an_error_message.yml +234 -0
  141. data/spec/cassettes/OiApi_Client_Offers/_update_offer/it_should_behave_like_PUT_resource/bad_request/returns_an_error_status.yml +234 -0
  142. data/spec/cassettes/OiApi_Client_Offers/_update_offer/it_should_behave_like_PUT_resource/returns_200_OK.yml +234 -0
  143. data/spec/cassettes/OiApi_Client_Offers/_update_offer/it_should_behave_like_PUT_resource/returns_the_correct_message.yml +234 -0
  144. data/spec/cassettes/OiApi_Client_Offers/_update_offer/it_should_behave_like_PUT_resource/returns_the_correct_status.yml +315 -0
  145. data/spec/cassettes/OiApi_Client_Offers/_update_offer/it_should_behave_like_PUT_resource/when_offer_not_found/returns_404.yml +154 -0
  146. data/spec/cassettes/OiApi_Client_Offers/_update_offer/it_should_behave_like_PUT_resource/when_offer_not_found/returns_error_status.yml +114 -0
  147. data/spec/cassettes/OiApi_Client_Offers/_update_offer/it_should_behave_like_PUT_resource/when_offer_not_found/returns_not_found_error_message.yml +114 -0
  148. data/spec/cassettes/OiApi_Client_Reports/_reports/it_should_behave_like_GET_resources/returns_200_OK.yml +46 -0
  149. data/spec/cassettes/OiApi_Client_Reports/_reports/it_should_behave_like_GET_resources/returns_HTTParty_Response.yml +46 -0
  150. data/spec/cassettes/OiApi_Client_Reports/_reports/it_should_behave_like_GET_resources/returns_all_resources.yml +46 -0
  151. data/spec/cassettes/OiApi_Client_Reports/_reports/returns_a_report_summary.yml +46 -0
  152. data/spec/cassettes/OiApi_Client_Reports/_reports_with_query_params/retrieves_the_last_60_days_of_data.yml +42 -0
  153. data/spec/oi_api/client/advertisers_spec.rb +86 -0
  154. data/spec/oi_api/client/auto_responders_spec.rb +55 -0
  155. data/spec/oi_api/client/balances_spec.rb +22 -0
  156. data/spec/oi_api/client/cards_spec.rb +60 -0
  157. data/spec/oi_api/client/charges_spec.rb +9 -0
  158. data/spec/oi_api/client/data_transfers_spec.rb +95 -0
  159. data/spec/oi_api/client/offers_spec.rb +84 -0
  160. data/spec/oi_api/client/reports_spec.rb +31 -0
  161. data/spec/oi_api/client/subscriptions_spec.rb +11 -0
  162. data/spec/oi_api_spec.rb +49 -0
  163. data/spec/shared_examples_for_delete_resource.rb +37 -0
  164. data/spec/shared_examples_for_get_resource.rb +33 -0
  165. data/spec/shared_examples_for_get_resources.rb +15 -0
  166. data/spec/shared_examples_for_post_resource.rb +31 -0
  167. data/spec/shared_examples_for_put_resource.rb +46 -0
  168. data/spec/spec_helper.rb +60 -0
  169. data/spec/support/advertisers_factory.rb +22 -0
  170. data/spec/support/auto_responders_factory.rb +27 -0
  171. data/spec/support/balances_factory.rb +12 -0
  172. data/spec/support/cards_factory.rb +34 -0
  173. data/spec/support/charges_factory.rb +16 -0
  174. data/spec/support/data_transfers_factory.rb +34 -0
  175. data/spec/support/factory.rb +48 -0
  176. data/spec/support/offers_factory.rb +53 -0
  177. data/spec/support/reports_factory.rb +12 -0
  178. data/spec/support/subscriptions_factory.rb +16 -0
  179. data/spec_output.txt +341 -0
  180. metadata +487 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 3ec2819523ef00444ce014ef43cc6d24f1f0fea5
4
+ data.tar.gz: ced108a991f7395a937252c34cd0edc1a3c6de16
5
+ SHA512:
6
+ metadata.gz: 3bf83a170f596a3362128294bd45c7d80b82d85da6edbba9ec2641b51e4176fe8fa4a885678361f1f3e608badcf07b9244fda6ebb0cbf3c61057065228967388
7
+ data.tar.gz: 9101956f704cbb75962cffdac3b45b1a789b5d8552dceef494d60adf748c42488388d9283ee0f83f251bb48b6cab913a69b6f5264d0a1e3221fba59e3e715a99
data/.env.sample ADDED
@@ -0,0 +1,2 @@
1
+ TEST_OI_USERNAME=example_user
2
+ TEST_OI_PASSWORD=password
data/.gitignore ADDED
@@ -0,0 +1,3 @@
1
+ Gemfile.lock
2
+ pkg/*
3
+ .env
data/.rspec ADDED
@@ -0,0 +1,4 @@
1
+ --color
2
+ --order rand
3
+ --require spec_helper
4
+ --format documentation
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 2.2.2
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in oi-api-ruby.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2015 Jrod
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,35 @@
1
+ [![Code Climate](https://codeclimate.com/github/jspillers/oi-api-ruby/badges/gpa.svg)](https://codeclimate.com/github/jspillers/oi-api-ruby)
2
+ [![Test Coverage](https://codeclimate.com/github/jspillers/oi-api-ruby/badges/coverage.svg)](https://codeclimate.com/github/jspillers/oi-api-ruby)
3
+
4
+ # OiApi Ruby
5
+
6
+ TODO: Write a gem description
7
+
8
+ ## Installation
9
+
10
+ Add this line to your application's Gemfile:
11
+
12
+ gem 'oi-api-ruby'
13
+
14
+ And then execute:
15
+
16
+ $ bundle
17
+
18
+ Or install it yourself as:
19
+
20
+ $ gem install oi-api-ruby
21
+
22
+ ## Usage
23
+
24
+ TODO: Write usage instructions here
25
+
26
+ ## Contributing
27
+
28
+ 1. Fork it
29
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
30
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
31
+ 4. Push to the branch (`git push origin my-new-feature`)
32
+ 5. Create new Pull Request
33
+
34
+ ## Testing
35
+ 1. `cp .env.sample .env` and edit values accordingly
data/Rakefile ADDED
@@ -0,0 +1,9 @@
1
+ require 'bundler/gem_tasks'
2
+
3
+ begin
4
+ require 'rspec/core/rake_task'
5
+ RSpec::Core::RakeTask.new(:spec)
6
+
7
+ task default: :spec
8
+ rescue LoadError
9
+ end
data/api_issues.md ADDED
@@ -0,0 +1,89 @@
1
+ ## Soft deleting advertisers?
2
+
3
+ Creating an advertiser, then deleting it, then attempting to create another advertiser with the same name results in a validation error. I suspect that DELETEs via the API are soft deletes and then validation is being triggered by the soft deleted records.
4
+
5
+ This is a problem when trying to run automated tests against the API. Ideally, each individual test would involve a full setup and breakdown of test records. The problem described above forces the use of a long random string for the name field (to minimize chance of name reuse) and is undoubtedly creating a ton of records upstream.
6
+
7
+ ```
8
+ >> api.advertisers.size
9
+ => 0
10
+
11
+ >> api.create_advertiser('name': 'test advertiser', status_id: 1, category_id: 1010)
12
+ => {"status"=>"Create Successful", "message"=>"Advertiser successfully created", "id"=>39437}
13
+
14
+ >> api.advertisers.size
15
+ => 1
16
+
17
+ >> api.advertisers.first
18
+ => {"id"=>39437, "name"=>"test advertiser", "status_id"=>1, "category_id"=>1010, "key"=>"", "create_date"=>"2015-04-21T16:03:42", "modify_date"=>"2015-04-21T16:03:42"}
19
+
20
+ >> api.delete_advertiser(39437)
21
+ => {"status"=>"Delete Successful", "message"=>"Advertiser Succesfully deleted"}
22
+
23
+ >> api.advertisers.size
24
+ => 0
25
+
26
+ >> api.create_advertiser('name': 'test advertiser', status_id: 1, category_id: 1010)
27
+ => {"status"=>"Create Failed", "message"=>"Name exists"}
28
+ ```
29
+
30
+ ## Need test card numbers for proper testing of POST, PUT /advertisers/123/cards/
31
+
32
+ ## HTTP Status codes inconsistent when a resource doesn't exist
33
+
34
+ When various operations are carried out on id's that do not exist, there are many inconsistencies in the various responses. All of the endpoints below should behave consistently when carrying out a request against a resource that does not exist:
35
+
36
+ #### PUT /advertisers/9999999999999/
37
+
38
+ Currently returns:
39
+ * HTTP status code: 400
40
+ * message: 'No permission to update advertiser'
41
+ * status: 'Update Failed'
42
+
43
+ More appropriate and consistent would be:
44
+ * HTTP status code: 404
45
+ * message: 'Record not found'
46
+ * status: 'error'
47
+
48
+ #### GET /advertisers/9999999999999/
49
+
50
+ Currently returns:
51
+ * HTTP status code: 400
52
+ * message: 'No permission to view advertiser.'
53
+ * status: 'Retrieve Failed'
54
+
55
+ More appropriate and consistent would be:
56
+ * HTTP status code: 404
57
+ * message: 'Record not found'
58
+ * status: 'error'
59
+
60
+ #### DELETE /advertisers/9999999999999/
61
+
62
+ Currently returns:
63
+ * HTTP status code: 403
64
+ * message: 'Operation not allowed'
65
+ * status: 'Request Failed'
66
+
67
+ More appropriate and consistent would be:
68
+ * HTTP status code: 404
69
+ * message: 'Record not found'
70
+ * status: 'error'
71
+
72
+ # DataTransfer messaging
73
+
74
+ In some places "Data Transfer" is returned in messages, but in others "DataTransfer" is returned. This should probably be consistent.
75
+
76
+ ## Consider nesting and scoping offers under advertisers (ie: /advertisers/123/offers/)
77
+
78
+ The API should return all offers when performing a GET to /offers/ but should return only offers for a given advertiser when scoped by advertiser_id (GET /advertisers/123/offers/).
79
+
80
+ ## Typo in successful Update for offers
81
+
82
+ when POSTing to /offers/123/ the "status" param returned has a typo: "Request Succesful" should be "Request Successful"
83
+
84
+ ## Are DELETE requests not allowed for offers?
85
+
86
+ ## Data transfers POST params redundancy
87
+
88
+ Data transfers endpoint example POST params has an offer_id in both the URI and in the POST body. If the offer_id is coming from a nested resource it should probably be omitted from the POST body.
89
+
data/lib/oi_api.rb ADDED
@@ -0,0 +1,12 @@
1
+ require 'oi_api/configuration'
2
+ require 'oi_api/client'
3
+
4
+ module OiApi
5
+
6
+ extend Configuration
7
+
8
+ def self.new(options={})
9
+ Client.new(options)
10
+ end
11
+
12
+ end
@@ -0,0 +1,98 @@
1
+ require 'httparty'
2
+ require 'oi_api/lookup_tables'
3
+ require 'oi_api/client/advertisers'
4
+ require 'oi_api/client/cards'
5
+ require 'oi_api/client/charges'
6
+ require 'oi_api/client/subscriptions'
7
+ require 'oi_api/client/balances'
8
+ require 'oi_api/client/offers'
9
+ require 'oi_api/client/data_transfers'
10
+ require 'oi_api/client/auto_responders'
11
+ require 'oi_api/client/reports'
12
+
13
+ module OiApi
14
+
15
+ class Client
16
+
17
+ include HTTParty
18
+ include OiApi::LookupTables
19
+ include OiApi::Client::Advertisers
20
+ include OiApi::Client::Cards
21
+ include OiApi::Client::Charges
22
+ include OiApi::Client::Subscriptions
23
+ include OiApi::Client::Balances
24
+ include OiApi::Client::Offers
25
+ include OiApi::Client::DataTransfers
26
+ include OiApi::Client::AutoResponders
27
+ include OiApi::Client::Reports
28
+
29
+ # setup accessors on this client for all config keys
30
+ attr_accessor *Configuration::VALID_CONFIG_KEYS
31
+
32
+ def initialize(options = {})
33
+ # Use options passed in, but fall back to config module defaults
34
+ merged_options = OiApi.options.merge(options)
35
+
36
+ # Copy the merged values to this client and ignore those
37
+ # not part of our configuration
38
+ OiApi::Configuration::VALID_CONFIG_KEYS.each do |key|
39
+ public_send("#{key}=", merged_options[key])
40
+ end
41
+
42
+ # set base_uri and format via HTTParty class methods
43
+ self.class.base_uri(api_endpoint)
44
+ self.class.format(format)
45
+ end
46
+
47
+ def get(url, options = {})
48
+ self.class.get url, options_with_basic_auth(options)
49
+ end
50
+
51
+ def post(url, options = {})
52
+ self.class.post url, options_with_basic_auth(options)
53
+ end
54
+
55
+ def put(url, options = {})
56
+ self.class.put url, options_with_basic_auth(options)
57
+ end
58
+
59
+ def delete(url, options = {})
60
+ self.class.delete url, options_with_basic_auth(options)
61
+ end
62
+
63
+ private
64
+
65
+ def basic_auth_options
66
+ {
67
+ :username => username,
68
+ :password => password
69
+ }
70
+ end
71
+
72
+ def default_header_options
73
+ {
74
+ 'Content-Type' => content_type,
75
+ 'User-Agent' => user_agent
76
+ }
77
+ end
78
+
79
+ def options_with_basic_auth(options = {})
80
+ headers = options.has_key?(:headers) ? options.delete(:headers) : {}
81
+ query_string = options.has_key?(:query) ? options.delete(:query) : {}
82
+ body = options
83
+
84
+ _options = {
85
+ basic_auth: basic_auth_options,
86
+ headers: default_header_options.merge(headers),
87
+ }
88
+
89
+ _options[:debug_output] = debug_output if debug_output
90
+ _options[:body] = body.to_json unless body.empty?
91
+ _options[:query] = query_string unless query_string.empty?
92
+
93
+ _options
94
+ end
95
+
96
+ end
97
+
98
+ end
@@ -0,0 +1,31 @@
1
+ module OiApi
2
+
3
+ class Client
4
+
5
+ module Advertisers
6
+
7
+ def advertisers(options = {})
8
+ get '/advertisers/', options
9
+ end
10
+
11
+ def advertiser(advertiser_id, options = {})
12
+ get "/advertisers/#{advertiser_id}/", options
13
+ end
14
+
15
+ def create_advertiser(options = {})
16
+ post '/advertisers/', options
17
+ end
18
+
19
+ def update_advertiser(advertiser_id, options = {})
20
+ put "/advertisers/#{advertiser_id}/", options
21
+ end
22
+
23
+ def delete_advertiser(advertiser_id, options = {})
24
+ delete "/advertisers/#{advertiser_id}/", options
25
+ end
26
+
27
+ end
28
+
29
+ end
30
+
31
+ end
@@ -0,0 +1,35 @@
1
+ module OiApi
2
+
3
+ class Client
4
+
5
+ module AutoResponders
6
+
7
+ def all_auto_responders(options = {})
8
+ get '/autoresponders/', options
9
+ end
10
+
11
+ def auto_responders(offer_id, options = {})
12
+ get "/offers/#{offer_id}/autoresponders/", options
13
+ end
14
+
15
+ def auto_responder(offer_id, auto_responder_id, options = {})
16
+ get "/offers/#{offer_id}/autoresponders/#{auto_responder_id}/", options
17
+ end
18
+
19
+ def create_auto_responder(offer_id, options = {})
20
+ post "/offers/#{offer_id}/autoresponders/", options
21
+ end
22
+
23
+ def update_auto_responder(offer_id, auto_responder_id, options = {})
24
+ put "/offers/#{offer_id}/autoresponders/#{auto_responder_id}/", options
25
+ end
26
+
27
+ #def delete_auto_responder(offer_id, auto_responder_id, options = {})
28
+ # delete "/offers/#{offer_id}/autoresponders/#{auto_responder_id}/", options
29
+ #end
30
+
31
+ end
32
+
33
+ end
34
+
35
+ end
@@ -0,0 +1,15 @@
1
+ module OiApi
2
+
3
+ class Client
4
+
5
+ module Balances
6
+
7
+ def balance(advertiser_id, options = {})
8
+ get "/advertisers/#{advertiser_id}/balance/", options
9
+ end
10
+
11
+ end
12
+
13
+ end
14
+
15
+ end
@@ -0,0 +1,33 @@
1
+ module OiApi
2
+
3
+ class Client
4
+
5
+ module Cards
6
+
7
+ # no GET all?
8
+ #def cards(advertiser_id, options = {})
9
+ # get "/advertisers/#{advertiser_id}/cards/", options
10
+ #end
11
+
12
+ def card(advertiser_id, card_id, options = {})
13
+ get "/advertisers/#{advertiser_id}/cards/#{card_id}/", options
14
+ end
15
+
16
+ def create_card(advertiser_id, options = {})
17
+ post "/advertisers/#{advertiser_id}/cards/", options
18
+ end
19
+
20
+ def update_card(advertiser_id, card_id, options = {})
21
+ put "/advertisers/#{advertiser_id}/cards/#{card_id}/", options
22
+ end
23
+
24
+ # no delete?
25
+ #def delete_card(advertiser_id, card_id, options = {})
26
+ # delete "/advertisers/#{advertiser_id}/cards/#{card_id}/", options
27
+ #end
28
+
29
+ end
30
+
31
+ end
32
+
33
+ end
@@ -0,0 +1,15 @@
1
+ module OiApi
2
+
3
+ class Client
4
+
5
+ module Charges
6
+
7
+ def create_charge(advertiser_id, options = {})
8
+ post "/advertisers/#{advertiser_id}/charges/", options
9
+ end
10
+
11
+ end
12
+
13
+ end
14
+
15
+ end