Sha256: 4d5b834c21c90d06deb91c18d1f37d0114635ab72b8263ccd0ac2150eebea7b3

Contents?: true

Size: 1.47 KB

Versions: 17

Compression:

Stored size: 1.47 KB

Contents

require 'blurb/request'

class Blurb
  class SuggestedKeywordRequests
    def initialize(base_url:, headers:)
      @base_url = base_url
      @headers = headers
    end

    def ad_group_retrieve(ad_group_id)
      execute_request(
        api_path: "/adGroups/#{ad_group_id}/suggested/keywords",
        request_type: :get
      )
    end

    def ad_group_retrieve_extended(ad_group_id)
      execute_request(
        api_path: "/adGroups/#{ad_group_id}/suggested/keywords/extended",
        request_type: :get
      )
    end

    def asin_retrieve(asin_value, max_num_suggestions=100)
      url_params = {max_num_suggestions: max_num_suggestions}
      execute_request(
        api_path: "/asins/#{asin_value}/suggested/keywords",
        request_type: :get,
        url_params: url_params
      )
    end

    def asin_list(asin_list, max_num_suggestions=100)
      url_params = {max_num_suggestions: max_num_suggestions}
      execute_request(
        api_path: '/asins/suggested/keywords',
        request_type: :post,
        payload: {
          asins: asin_list,
          max_num_suggestions: max_num_suggestions
        }
      )
    end

    private

    def execute_request(api_path: "", request_type:, payload: nil, url_params: nil)
      url = "#{@base_url}#{api_path}"

      request = Request.new(
        url: url,
        url_params: url_params,
        request_type: request_type,
        payload: payload,
        headers: @headers
      )

      request.make_request
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
blurb-0.5.9 lib/blurb/suggested_keyword_requests.rb
blurb-0.5.8 lib/blurb/suggested_keyword_requests.rb
blurb-0.5.6 lib/blurb/suggested_keyword_requests.rb
blurb-0.5.5 lib/blurb/suggested_keyword_requests.rb
blurb-0.5.2 lib/blurb/suggested_keyword_requests.rb
blurb-0.5.1 lib/blurb/suggested_keyword_requests.rb
blurb-0.4.12 lib/blurb/suggested_keyword_requests.rb
blurb-0.4.11 lib/blurb/suggested_keyword_requests.rb
blurb-0.4.10 lib/blurb/suggested_keyword_requests.rb
blurb-0.4.8 lib/blurb/suggested_keyword_requests.rb
blurb-0.4.7 lib/blurb/suggested_keyword_requests.rb
blurb-0.4.6 lib/blurb/suggested_keyword_requests.rb
blurb-0.4.5 lib/blurb/suggested_keyword_requests.rb
blurb-0.4.4 lib/blurb/suggested_keyword_requests.rb
blurb-0.4.2 lib/blurb/suggested_keyword_requests.rb
blurb-0.4.1 lib/blurb/suggested_keyword_requests.rb
blurb-0.4.0 lib/blurb/suggested_keyword_requests.rb