Class: GrowViral::Keystore::AccountCreator
- Inherits:
-
Object
- Object
- GrowViral::Keystore::AccountCreator
- Defined in:
- lib/keystore/account_creator.rb
Instance Attribute Summary collapse
-
#application_id ⇒ Object
readonly
Returns the value of attribute application_id.
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#handle ⇒ Object
readonly
Returns the value of attribute handle.
-
#secret ⇒ Object
readonly
Returns the value of attribute secret.
-
#token ⇒ Object
readonly
Returns the value of attribute token.
-
#uid ⇒ Object
readonly
Returns the value of attribute uid.
Class Method Summary collapse
Instance Method Summary collapse
- #create ⇒ Object
- #form_data ⇒ Object
-
#initialize(application_id, handle, uid, token, secret, deps) ⇒ AccountCreator
constructor
A new instance of AccountCreator.
- #uri ⇒ Object
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_id ⇒ Object (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 |
#config ⇒ Object (readonly)
Returns the value of attribute config.
8 9 10 |
# File 'lib/keystore/account_creator.rb', line 8 def config @config end |
#handle ⇒ Object (readonly)
Returns the value of attribute handle.
8 9 10 |
# File 'lib/keystore/account_creator.rb', line 8 def handle @handle end |
#secret ⇒ Object (readonly)
Returns the value of attribute secret.
8 9 10 |
# File 'lib/keystore/account_creator.rb', line 8 def secret @secret end |
#token ⇒ Object (readonly)
Returns the value of attribute token.
8 9 10 |
# File 'lib/keystore/account_creator.rb', line 8 def token @token end |
#uid ⇒ Object (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
#create ⇒ Object
18 19 20 21 |
# 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 ⇒ Object
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 |
#uri ⇒ Object
23 24 25 |
# File 'lib/keystore/account_creator.rb', line 23 def uri @uri ||= URI.parse("#{config.host}/applications/#{application_id}/accounts") end |