lib/access/api.rb in access-1.1.7 vs lib/access/api.rb in access-2.0.0

- old
+ new

@@ -1,145 +1,269 @@ module Access - class Api < Request + class Api # Categories def search_categories(options = {}) - get("/categories", "offer", options) + request.get("/categories", "offer", options) do |response| + CategoryResponse.new(response) + end end - def find_category(category_id, options = {}) - get("/categories/#{category_id}", "offer", options) + def find_category(category_key, options = {}) + request.get("/categories/#{category_key}", "offer", options) do |response| + CategoryResponse.new(response) + end end - # Offers - def search_offers(options={}) - get("/offers", "offer", options) + def search_offers(options = {}) + request.get("/offers", "offer", options) do |response| + OfferResponse.new(response) + end end - def find_offer(offer_id, options = {}) - get("/offers/#{offer_id}", "offer", options) + def find_offer(offer_key, options = {}) + request.get("/offers/#{offer_key}", "offer", options) do |response| + OfferResponse.new(response) + end end - # Locations - def search_locations(options={}) - get("/locations", "offer", options) + def search_locations(options = {}) + request.get("/locations", "offer", options) do |response| + LocationResponse.new(response) + end end - def find_location(location_id, options = {}) - get("/locations/#{location_id}", "offer", options) + def find_location(location_key, options = {}) + request.get("/locations/#{location_key}", "offer", options) do |response| + LocationResponse.new(response) + end end - # Stores - def search_stores(options={}) - get("/stores", "offer", options) + def search_stores(options = {}) + request.get("/stores", "offer", options) do |response| + StoreResponse.new(response) + end end - def find_store(store_id, options = {}) - get("/stores/#{store_id}", "offer", options) + def find_store(store_key, options = {}) + request.get("/stores/#{store_key}", "offer", options) do |response| + StoreResponse.new(response) + end end def national_stores(options={}) - get("/stores/national", "offer", options) + request.get("/stores/national", "offer", options) do |response| + StoreResponse.new(response) + end end - # Autocomplete def autocomplete(options = {}) - get("/autocomplete", "offer", options) + request.get("/autocomplete", "offer", options) do |response| + AutocompleteResponse.new(response) + end end + # Redeem + def redeem_offer(offer_key, redeem_type = nil, options = {}) + request.get("/redeem/#{offer_key}/#{redeem_type}", "redeem", options) do |response| + RedeemResponse.new(response) + end + end - # Filters - def search_filters(options = {}) - get('/filters', 'token', options) + # CitySavings + def search_city_savings(options = {}) + # this is broken + request.get("/citysavings", "allcitysavings", options) do |response| + CitySavingsResponse.new(response) + end end - def find_filter(application_id, options = {}) - get("/filters/#{application_id}", 'token', options) + # Channel + def search_channels(options = {}) + request.get("/channels", "campaign", options) do |response| + ChannelResponse.new(response) + end end + def find_channel(channel_key, options = {}) + request.get("/channels/#{channel_key}", "campaign", options) do |response| + ChannelResponse.new(response) + end + end - # Oauth Applications - def search_oauth_applications(options = {}) - get('/oauth_applications', 'token', options) + # Campaign + def search_campaigns(options = {}) + request.get("/campaigns", "campaign", options) do |response| + ChampaignResponse.new(response) + end end - def find_oauth_application(application_id, options = {}) - get("/oauth_applications/#{application_id}", 'token', options) + def find_campaign(campaign_key, options = {}) + request.get("/campaigns/#{store_key}", "campaign", options) do |response| + ChampaignResponse.new(response) + end end - def search_oauth_application_tokens(application_id, options = {}) - get("/oauth_applications/#{application_id}/access_tokens", 'token', options) + # Spot + def search_spots_by_channel(channel_key, options = {}) + request.get("/spots/channel/#{channel_key}", "campaign", options) do |response| + SpotResponse.new(response) + end end - def find_oauth_application_token(application_id, token_id, options = {}) - get("/oauth_applications/#{application_id}/access_tokens/#{token_id}", 'token', options) + def search_spots_by_campaign(campaign_key, options = {}) + request.get("/spots/campaign/#{campaign_key}", "campaign", options) do |response| + SpotResponse.new(response) + end end - def create_oauth_application_token(application_id, options = {}) - create("/oauth_applications/#{application_id}/access_tokens", 'token', options) + def find_spot(spot_key, options = {}) + request.get("/spots/#{spot_key}", "campaign", options) do |response| + SpotResponse.new(response) + end end - def create_oauth_application(options = {}) - create("/oauth_applications", 'token', options) + # Member + + # Internal Admin only Call Below + + # Filters + def search_filters(options = {}) + # Internal Admin only Call + request.get("/filters", "token", options) do |response| + FilterResponse.new(response) + end end - def update_oauth_application(application_id, options = {}) - put("/oauth_applications/#{application_id}", 'token', options) + def find_filter(application_key, options = {}) + # Internal Admin only Call + request.get("/filters/#{application_key}", "token", options) do |response| + FilterResponse.new(response) + end end - def delete_oauth_application(application_id, options = {}) - delete("/oauth_applications/#{application_id}", 'token', options) + # Oauth Applications + def search_oauth_applications(options = {}) + # Internal Admin only Call + request.get("/oauth_applications", 'token', options) do |response| + OauthApplicationResponse.new(response) + end end + def find_oauth_application(application_key, options = {}) + # Internal Admin only Call + request.get("/oauth_applications/#{application_key}", 'token', options) do |response| + OauthApplicationResponse.new(response) + end + end - # Access Tokens - def search_tokens(options = {}) - get('/tokens', 'token', options) + def search_oauth_application_tokens(application_key, options = {}) + # Internal Admin only Call + request.get("/oauth_applications/#{application_key}/access_tokens", 'token', options) do |response| + TokenResponse.new(response) + end end - def find_token(token, options = {}) # new verify_other - get("/tokens/#{token}", "token", options) + def find_oauth_application_token(application_key, token_key, options = {}) + # Internal Admin only Call + request.get("/oauth_applications/#{application_key}/access_tokens/#{token_key}", 'token', options) do |response| + TokenResponse.new(response) + end end + def create_oauth_application_token(application_key, options = {}) + # Internal Admin only Call + request.create("/oauth_applications/#{application_key}/access_tokens", 'token', options) do |response| + # TokenResponse.new(response) + # OauthApplicationResponse.new(response) + end + # create("/oauth_applications/#{application_key}/access_tokens", 'token', options) + end - # Verify - def verify_token(options = {}) - get('/verify', 'token', options) + def create_oauth_application(options = {}) + # Internal Admin only Call + request.create("/oauth_applications", 'token', options) do |response| + OauthApplicationResponse.new(response) + end + # create("/oauth_applications", 'token', options) end - def verify_filter(options = {}) - get_json('/filter', 'token', options) + def update_oauth_application(application_key, batch= {}) + # Internal Admin only Call + request.put("/oauth_applications/#{application_key}", 'token', options) do |response| + OauthApplicationResponse.new(response) + end + # put("/oauth_applications/#{application_key}", 'token', options) end + def delete_oauth_application(application_key, options = {}) + # Internal Admin only Call + request.delete("/oauth_applications/#{application_key}", 'token', options) do |response| + OauthApplication.new(response) + end + # delete("/oauth_applications/#{application_key}", 'token', options) + end - # Redeem - def redeem_offer(offer_key, redeem_type = nil, options = {}) - get("/redeem/#{offer_key}/#{redeem_type}", "redeem", options) + # Access Tokens + def search_tokens(options = {}) + # Internal Admin only Call + request.get("/tokens", 'token', options) do |response| + TokenResponse.new(response) + end end - def citysavings(options = {}) - get("/citysavings", "allcitysavings", options) + def find_token(token, options = {}) + # Internal Admin only Call + # new verify_other + request.get("/tokens/#{token}", "token", options) do |response| + TokenResponse.new(response) + end end + # Verify + def verify_token(options = {}) + # Internal Admin only Call + request.get("/verify", 'token', options) do |response| + VerifyResponse.new(response) + end + end + def verify_filter(filter, options = {}) + # Internal Admin only Call + request.get_for_filter("/filter", 'token', filter, options) do |response| + VerifyResponse.new(response) + end + end + # Report def all_usage(options = {}) - get("/all_usage", "report", options) + # Internal Admin only Call + request.get("/all_usage", "report", options) do |response| + ReportResponse.new(response) + end end def usage(options = {}) - get("/usage", "report", options) + # Internal Admin only Call + request.get("/usage", "report", options) do |response| + ReportResponse.new(response) + end end def usage_other(token, options = {}) - get("/usage/#{token}", "report", options) + # Internal Admin only Call + request.get("/usage/#{token}", "report", options) do |response| + ReportResponse.new(response) + end end + private - # Member - + def request + Access::Request.new + end end end