Sha256: 130908f233a49a7788c872b1917277419fddcffa8877bd724801aa713773f816

Contents?: true

Size: 995 Bytes

Versions: 1

Compression:

Stored size: 995 Bytes

Contents

module Mugen
  class Client
    include HTTParty
    base_uri Mugen.api_url || 'http://api.sandbox.mygengo.com/v1/'
    headers = {
      'Accept' => 'application/json',
      'User-Agent' => 'myGengo Mugen Rails API Wrapper; Version 0.0.1; http://github.com/shell/mugen'
    }

    # debug_output $stderr                                

    def self.before_get(path, options)
      options[:query] = Mugen.set_params(options[:query]) if options.has_key? :query
      [path, options]
    end
    
    def self.before_post(path, options)
      options[:body] = Mugen.set_params(options[:body], :post) if options.has_key? :body
      [path, options]
    end
    
    def self.before_put(path, options)
      options[:body] = Mugen.set_params(options[:body], :post) if options.has_key? :body
      [path, options]
    end
    
    def self.check_for_errors(res)
      if res['opstat'] != 'ok' && res['err']
        Mugen.errors << res['err']['msg']
      end
    end
  end                     
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
mugen-0.2.1 lib/mugen/client.rb