Sha256: 71212078713c1884c40bd82e84e10a5f9b598275eba82c4de6743fdbf67687c0

Contents?: true

Size: 1.01 KB

Versions: 2

Compression:

Stored size: 1.01 KB

Contents

require 'aptible/auth'
require 'stripe'

module Aptible
  module Api
    class Account < Resource
      has_many :apps
      has_many :databases
      has_many :disks
      has_many :services
      has_many :permissions

      field :id
      field :type
      field :name
      field :handle
      field :number
      field :type
      field :activated, type: Aptible::Resource::Boolean
      field :syslog_host
      field :syslog_port
      field :created_at, type: Time
      field :updated_at, type: Time

      def production?
        type == 'production'
      end

      def operations
        # TODO: Implement /accounts/:id/operations
        []
      end

      def organization
        auth = Aptible::Auth::Organization.new(token: token, headers: headers)
        auth.find_by_url(links['organization'].href)
      end

      def self.generate_handle(organization_name, plan_id)
        rand = ('a'..'z').to_a.shuffle[0, 8].join
        "#{organization_name.parameterize}-#{plan_id}-#{rand}"
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
aptible-api-0.7.1 lib/aptible/api/account.rb
aptible-api-0.7.0 lib/aptible/api/account.rb