Sha256: 0fc0a38100fde5068208acd785365f91f7eda5e2df9e9e818ca436dd578c5d1b

Contents?: true

Size: 1.26 KB

Versions: 1

Compression:

Stored size: 1.26 KB

Contents

module Trigga
  module AdminApiClient
    module Proxies
      module Api

        def self.included(base)
          base.send("extend",self)
        end

        private
        
        def common_params
          [:page, :per_page, :max_tags, :site_key, :api_key]
        end
        
        def make_api_call(endpoint, opts = {})
          require_one_of( opts, :site_key, :site_id )
          Trigga::AdminApiClient.make_call("api", endpoint, opts.reject{|k,v| !common_params.include?(k.to_sym) } )
        end
        
        public
        
        def get_channels(opts)
          make_api_call("channels", opts )
        end
          
          def get_channel_items( opts )
          require_param( opts, :channel_id )
          make_api_call("channels/#{opts[:channel_id]}", opts )
        end
        
        def get_sources( opts )
          make_api_call('sources', opts)
        end
        
        def get_item_tags( opts )
          make_api_call('item_tags', opts)
        end
        
        def get_latest_items( opts )
          make_api_call('items', opts)
        end
        
        def get_item_details( opts )
          require_param( opts, :item_id )
          make_api_call("items/#{opts[:item_id]}", opts)
        end
         
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
itrigga-admin_api_client-0.1.2 lib/trigga/admin_api_client/proxies/api.rb