Sha256: 1da842be867f6c296a7579138e0b69fe0f46bb088d2d8ec38bfe83195f3c3a3b

Contents?: true

Size: 919 Bytes

Versions: 1

Compression:

Stored size: 919 Bytes

Contents

module EventbriteRuby
  class Client
    attr_accessor :personal_key, :password

    def initialize(personal_key: nil)
      @personal_key = personal_key || EventbriteRuby.personal_key
    end

    def connection
      @connection ||= begin
        Faraday.new(:url => 'https://www.eventbriteapi.com/') do |faraday|
          faraday.authorization :Bearer, @personal_key
          faraday.response :json, :content_type => /\bjson$/
          faraday.adapter  Faraday.default_adapter  # make requests with Net::HTTP
        end
      end
    end

    def post(url, data)
      connection.post do |req|
        req.url url
        req.headers['Content-Type'] = 'application/json'
        req.body = data.to_json
      end
    end

    def get(url, data)
      connection.get do |req|
        req.url url
        req.headers['Content-Type'] = 'application/json'
        req.body = data.to_json
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
eventbrite_ruby-0.0.1 lib/eventbrite_ruby/Client.rb