Sha256: 77cedf2f1d9874c9f7f3127d278e4cff36bc188e2003644030bb1e3ace75e918

Contents?: true

Size: 1016 Bytes

Versions: 2

Compression:

Stored size: 1016 Bytes

Contents

#
# base_service.rb
# ConstantContact
#
# Copyright (c) 2013 Constant Contact. All rights reserved.

module ConstantContact
  module Services
    class BaseService
      class << self
        attr_accessor :api_key

        protected

        # Helper function to return required headers for making an http request with constant contact
        # @param [String] access_token - OAuth2 access token to be placed into the Authorization header
        # @return [Hash] - authorization headers
        def get_headers(access_token)
          {
            :content_type   => 'application/json',
            :accept         => 'application/json',
            :authorization  => "Bearer #{access_token}"
          }
        end


        # Build a url from the base url and query parameters hash
        def build_url(url, params = nil)
          params = {} if !params
          params['api_key'] = BaseService.api_key
          url += '?' + Util::Helpers.http_build_query(params)
        end

      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
constantcontact-1.0.2 lib/constantcontact/services/base_service.rb
constantcontact-1.0.1 lib/constantcontact/services/base_service.rb