class GroupMe::Client
Public Class Methods
new(options = {})
click to toggle source
# File lib/groupme/client.rb, line 11 def initialize(options = {}) @token = options[:token].to_s fail ArgumentError, ":token can't be blank" if @token.empty? end
Private Instance Methods
connection()
click to toggle source
Returns a Faraday::Connection object
@return [Faraday::Connection]
# File lib/groupme/client.rb, line 45 def connection @connection ||= Faraday.new 'https://api.groupme.com/' do |f| f.request :json f.headers[:user_agent] = GroupMe::USER_AGENT f.headers['X-Access-Token'] = @token # f.response :logger f.response :mashify f.response :json, :content_type => /\bjson$/ f.adapter Faraday.default_adapter end end
get(path, options = {})
click to toggle source
# File lib/groupme/client.rb, line 25 def get(path, options = {}) request(:get, path, options) end
post(path, data = {})
click to toggle source
# File lib/groupme/client.rb, line 29 def post(path, data = {}) request(:post, path, data) end
request(method, path, data = {})
click to toggle source
# File lib/groupme/client.rb, line 33 def request(method, path, data = {}) res = connection.send(method, "v3/#{path}", data) if res.success? && !res.body.empty? && res.body != ' ' res.body.response else res end end