class Assembla::Client::Authorizations

OAuth Authorizations API

Constants

VALID_AUTH_PARAM_NAMES

Public Instance Methods

all(*args)
Alias for: list
create(*args) click to toggle source

Create a new authorization

@param [Hash] params @option params [Array] :scopes

A list of scopes that this authorization is in.

@option params [String] :note

A note to remind you what the OAuth token is for.

@option params [String] :note_url

A URL to remind you what the OAuth token is for.

@option params [String] :client_id

The 20 character OAuth app client key for which to create the token.

@option params [String] :client_secret

The 40 character OAuth app client secret for which to create the token.

@example

assembla = Assembla.new basic_auth: 'login:password'
assembla.oauth.create
  "scopes" => ["public_repo"]

@api public

# File lib/assembla_api/client/authorizations.rb, line 81
def create(*args)
  raise_authentication_error unless authenticated?
  arguments(args) do
    permit VALID_AUTH_PARAM_NAMES
  end

  post_request('/authorizations', arguments.params)
end
delete(*args) click to toggle source

Delete an authorization

@see developer.assembla.com/v3/oauth_authorizations/#delete-an-authorization

@example

assembla.oauth.delete 'authorization-id'

@api public

# File lib/assembla_api/client/authorizations.rb, line 127
def delete(*args)
  raise_authentication_error unless authenticated?
  arguments(args, required: [:id])

  delete_request("/authorizations/#{arguments.id}", arguments.params)
end
Also aliased as: remove
edit(*args)
Alias for: update
find(*args)
Alias for: get
get(*args) click to toggle source

Get a single authorization

@see developer.assembla.com/v3/oauth_authorizations/#get-a-single-authorization

@example

assembla = Assembla.new basic_auth: 'login:password'
assembla.oauth.get 'authorization-id'

@return [ResponseWrapper]

@api public

# File lib/assembla_api/client/authorizations.rb, line 53
def get(*args)
  raise_authentication_error unless authenticated?
  arguments(args, required: [:id])

  get_request("/authorizations/#{arguments.id}", arguments.params)
end
Also aliased as: find
list(*args) { |el| ... } click to toggle source

List authorizations

@see developer.assembla.com/v3/oauth_authorizations/#list-your-authorizations

@example

assembla = Assembla.new basic_auth: 'login:password'
assembla.oauth.list
assembla.oauth.list { |auth| ... }

@api public

# File lib/assembla_api/client/authorizations.rb, line 32
def list(*args)
  raise_authentication_error unless authenticated?
  arguments(args)

  response = get_request('/authorizations', arguments.params)
  return response unless block_given?
  response.each { |el| yield el }
end
Also aliased as: all
remove(*args)
Alias for: delete
update(*args) click to toggle source

Update an existing authorization

@param [Hash] inputs @option inputs [Array] :scopes

Optional array - A list of scopes that this authorization is in.

@option inputs [Array] :add_scopes

Optional array - A list of scopes to add to this authorization.

@option inputs [Array] :remove_scopes

Optional array - A list of scopes to remove from this authorization.

@option inputs [String] :note

Optional string - A note to remind you what the OAuth token is for.

@optoin inputs [String] :note_url

Optional string - A URL to remind you what the OAuth token is for.

@example

assembla = Assembla.new basic_auth: 'login:password'
assembla.oauth.update "authorization-id", add_scopes: ["repo"]

@api public

# File lib/assembla_api/client/authorizations.rb, line 109
def update(*args)
  raise_authentication_error unless authenticated?
  arguments(args, required: [:id]) do
    permit VALID_AUTH_PARAM_NAMES
  end

  patch_request("/authorizations/#{arguments.id}", arguments.params)
end
Also aliased as: edit

Protected Instance Methods

raise_authentication_error() click to toggle source
# File lib/assembla_api/client/authorizations.rb, line 137
def raise_authentication_error
  raise ArgumentError, 'You can only access your own tokens' +
    ' via Basic Authentication'
end