class GrowViral::Keystore::AccountCreator

Attributes

application_id[R]
config[R]
handle[R]
secret[R]
token[R]
uid[R]

Public Class Methods

create(*args) click to toggle source
# File lib/keystore/account_creator.rb, line 4
def self.create(*args)
  new(*args).create
end
new(application_id, handle, uid, token, secret, deps) click to toggle source
# File lib/keystore/account_creator.rb, line 9
def initialize(application_id, handle, uid, token, secret, deps)
  @application_id = application_id
  @handle = handle
  @uid = uid
  @token = token
  @secret = secret
  @config = deps[:config]
end

Public Instance Methods

create() click to toggle source
# File lib/keystore/account_creator.rb, line 18
def create
  response = Net::HTTP.post_form(uri, form_data)
  Account.new JSON.parse(response.body)
end
form_data() click to toggle source
# File lib/keystore/account_creator.rb, line 27
def form_data
  {
    "account[handle]" => handle,
    "account[uid]" => uid,
    "account[token]" => token,
    "account[secret]" => secret
  }
end
uri() click to toggle source
# File lib/keystore/account_creator.rb, line 23
def uri
  @uri ||= URI.parse("#{config.host}/applications/#{application_id}/accounts")
end