class Scalingo::Auth::Tokens

Public Instance Methods

all(headers = nil, &block) click to toggle source
# File lib/scalingo/auth/tokens.rb, line 26
def all(headers = nil, &block)
  data = nil

  response = connection.get(
    "tokens",
    data,
    headers,
    &block
  )

  unpack(:tokens) { response }
end
create(payload, headers = nil, &block) click to toggle source
# File lib/scalingo/auth/tokens.rb, line 39
def create(payload, headers = nil, &block)
  data = {token: payload}

  response = connection.post(
    "tokens",
    data,
    headers,
    &block
  )

  unpack(:token) { response }
end
destroy(id, headers = nil, &block) click to toggle source
# File lib/scalingo/auth/tokens.rb, line 65
def destroy(id, headers = nil, &block)
  data = nil

  response = connection.delete(
    "tokens/#{id}",
    data,
    headers,
    &block
  )

  unpack { response }
end
exchange(token, headers = nil, &block) click to toggle source
# File lib/scalingo/auth/tokens.rb, line 5
def exchange(token, headers = nil, &block)
  data = nil

  authorization = Faraday::Request::BasicAuthentication.header("", token)

  request_headers = {
    Faraday::Request::Authorization::KEY => authorization,
  }

  request_headers.update(headers) if headers

  response = client.unauthenticated_connection.post(
    "tokens/exchange",
    data,
    request_headers,
    &block
  )

  unpack { response }
end
renew(id, headers = nil, &block) click to toggle source
# File lib/scalingo/auth/tokens.rb, line 52
def renew(id, headers = nil, &block)
  data = nil

  response = connection.patch(
    "tokens/#{id}/renew",
    data,
    headers,
    &block
  )

  unpack(:token) { response }
end