Module: PlatformAPI

Defined in:
lib/platform-api.rb,
lib/platform-api/client.rb,
lib/platform-api/version.rb

Overview

Ruby HTTP client for the Heroku API.

Defined Under Namespace

Classes: Account, AccountFeature, Addon, AddonAction, AddonAttachment, AddonRegionCapability, AddonService, App, AppFeature, AppSetup, AppTransfer, Build, BuildResult, BuildpackInstallation, Client, Collaborator, ConfigVar, Credit, Domain, Dyno, Event, FailedEvent, FilterApps, Formation, InboundRuleset, Invitation, Invoice, InvoiceAddress, Key, LogDrain, LogSession, OauthAuthorization, OauthClient, OauthGrant, OauthToken, Organization, OrganizationAddon, OrganizationApp, OrganizationAppCollaborator, OrganizationInvoice, OrganizationMember, OrganizationPaymentMethod, OrganizationPreferences, OtpSecret, PasswordReset, Payment, PaymentMethod, Pipeline, PipelineCoupling, PipelinePromotion, PipelinePromotionTarget, Plan, RateLimit, RecoveryCode, Region, Release, SSLEndpoint, Slug, SmsNumber, Source, Space, SpaceAppAccess, SpaceNat, Stack, UserPreferences, WhitelistedAddonService

Constant Summary collapse

VERSION =
'0.7.0'

Class Method Summary collapse

Class Method Details

.connect(api_key, options = nil) ⇒ Client

Get a Client configured to use HTTP Basic authentication.

Parameters:

  • api_key (String)

    The API key to use when connecting.

  • options (Hash<Symbol,String>) (defaults to: nil)

    Optionally, custom settings to use with the client. Allowed options are default_headers, cache, user and url.

Returns:

  • (Client)

    A client configured to use the API with HTTP Basic authentication.



22
23
24
25
26
27
28
29
# File 'lib/platform-api/client.rb', line 22

def self.connect(api_key, options=nil)
  options = custom_options(options)
  uri = URI.parse(options[:url])
  uri.user = URI.encode_www_form_component options.fetch(:user, 'user')
  uri.password = api_key
  client = Heroics.client_from_schema(SCHEMA, uri.to_s, options)
  Client.new(client)
end

.connect_oauth(oauth_token, options = nil) ⇒ Client

Get a Client configured to use OAuth authentication.

Parameters:

  • oauth_token (String)

    The OAuth token to use with the API.

  • options (Hash<Symbol,String>) (defaults to: nil)

    Optionally, custom settings to use with the client. Allowed options are default_headers, cache and url.

Returns:

  • (Client)

    A client configured to use the API with OAuth authentication.



39
40
41
42
43
44
# File 'lib/platform-api/client.rb', line 39

def self.connect_oauth(oauth_token, options=nil)
  options = custom_options(options)
  url = options[:url]
  client = Heroics.oauth_client_from_schema(oauth_token, SCHEMA, url, options)
  Client.new(client)
end

.connect_token(token, options = nil) ⇒ Client

Get a Client configured to use Token authentication.

Parameters:

  • token (String)

    The token to use with the API.

  • options (Hash<Symbol,String>) (defaults to: nil)

    Optionally, custom settings to use with the client. Allowed options are default_headers, cache and url.

Returns:

  • (Client)

    A client configured to use the API with OAuth authentication.



54
55
56
57
58
59
# File 'lib/platform-api/client.rb', line 54

def self.connect_token(token, options=nil)
  options = custom_options(options)
  url = options[:url]
  client = Heroics.token_client_from_schema(token, SCHEMA, url, options)
  Client.new(client)
end