Class: GrowViral::Keystore::AccountCreator

Inherits:
Object
  • Object
show all
Defined in:
lib/keystore/account_creator.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(application_id, handle, uid, token, secret, deps) ⇒ AccountCreator

Returns a new instance of AccountCreator.



9
10
11
12
13
14
15
16
# 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

Instance Attribute Details

#application_idObject (readonly)

Returns the value of attribute application_id.



8
9
10
# File 'lib/keystore/account_creator.rb', line 8

def application_id
  @application_id
end

#configObject (readonly)

Returns the value of attribute config.



8
9
10
# File 'lib/keystore/account_creator.rb', line 8

def config
  @config
end

#handleObject (readonly)

Returns the value of attribute handle.



8
9
10
# File 'lib/keystore/account_creator.rb', line 8

def handle
  @handle
end

#secretObject (readonly)

Returns the value of attribute secret.



8
9
10
# File 'lib/keystore/account_creator.rb', line 8

def secret
  @secret
end

#tokenObject (readonly)

Returns the value of attribute token.



8
9
10
# File 'lib/keystore/account_creator.rb', line 8

def token
  @token
end

#uidObject (readonly)

Returns the value of attribute uid.



8
9
10
# File 'lib/keystore/account_creator.rb', line 8

def uid
  @uid
end

Class Method Details

.create(*args) ⇒ Object



4
5
6
# File 'lib/keystore/account_creator.rb', line 4

def self.create(*args)
  new(*args).create
end

Instance Method Details

#createObject



18
19
20
21
# File 'lib/keystore/account_creator.rb', line 18

def create
  response = Net::HTTP.post_form(uri, form_data)
  .new JSON.parse(response.body)
end

#form_dataObject



27
28
29
30
31
32
33
34
# File 'lib/keystore/account_creator.rb', line 27

def form_data
  {
    "account[handle]" => handle,
    "account[uid]" => uid,
    "account[token]" => token,
    "account[secret]" => secret
  }
end

#uriObject



23
24
25
# File 'lib/keystore/account_creator.rb', line 23

def uri
  @uri ||= URI.parse("#{config.host}/applications/#{application_id}/accounts")
end