class Fellowshipone::Client

Attributes

church_code[R]
consumer_key[R]
consumer_secret[R]
logger[R]
secret[R]
token[R]

Public Class Methods

new(church_code:, consumer_key:, consumer_secret:, token:, secret:, logger: false) click to toggle source
# File lib/fellowshipone/client.rb, line 20
def initialize(church_code:, consumer_key:, consumer_secret:, token:, secret:, logger: false)
  @church_code     = church_code
  @consumer_key    = consumer_key
  @consumer_secret = consumer_secret
  @token           = token
  @secret          = secret
  @logger          = logger
end

Public Instance Methods

delete(path, options = {}) click to toggle source
# File lib/fellowshipone/client.rb, line 41
def delete(path, options = {})
  connection.delete(path, options).body
end
get(path, options = {}) click to toggle source
# File lib/fellowshipone/client.rb, line 29
def get(path, options = {})
  connection.get(path, options).body
end
post(path, options = {}) click to toggle source
# File lib/fellowshipone/client.rb, line 33
def post(path, options = {})
  connection.post(path, options).body
end
put(path, options = {}) click to toggle source
# File lib/fellowshipone/client.rb, line 37
def put(path, options = {})
  connection.put(path, options).body
end
save() click to toggle source
# File lib/fellowshipone/client.rb, line 45
def save
  connection.put(path, {}).body
end

Private Instance Methods

connection() click to toggle source
# File lib/fellowshipone/client.rb, line 51
def connection
  Faraday.new(url: "https://#{church_code}.fellowshiponeapi.com", headers: { accept: 'application/json' }) do |connection|
    connection.request  :json
    connection.request  :oauth, oauth_data
    connection.response :logger if logger
    connection.use      FaradayMiddleware::Mashify
    connection.response :json
    connection.adapter  Faraday.default_adapter
  end
end
oauth_data() click to toggle source
# File lib/fellowshipone/client.rb, line 62
def oauth_data
  {
    consumer_key:    consumer_key,
    consumer_secret: consumer_secret,
    token:           token,
    token_secret:    secret
  }
end