Class: Singly::Account

Inherits:
Object
  • Object
show all
Defined in:
lib/singly/account.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(access_token, account = nil) ⇒ Account

Returns a new instance of Account.



5
6
7
8
# File 'lib/singly/account.rb', line 5

def initialize(access_token, =nil)
  @access_token = access_token
  @account = 
end

Instance Attribute Details

#access_tokenObject (readonly)

Returns the value of attribute access_token.



3
4
5
# File 'lib/singly/account.rb', line 3

def access_token
  @access_token
end

Instance Method Details

#account_idObject



10
11
12
# File 'lib/singly/account.rb', line 10

def 
  @account ||= profiles.fetch["id"]
end

#apply(service, params) ⇒ Object

Shortcut to Singly.auth.<service>.apply(account: <account_id>, token: <token> [, token_secret: <token_secret>]) where <account_id> is always this account’s account_id. If the account_id is not present, it is fetched from the api.



59
60
61
# File 'lib/singly/account.rb', line 59

def apply(service, params)
  Singly.auth.send(service).apply(params.merge(account: ))
end

#delete(service, id = nil) ⇒ Object

Alternative to calling #profiles.<service>.delete. Useful if you don’t know the exact service at runtime.



44
45
46
47
48
# File 'lib/singly/account.rb', line 44

def delete(service, id=nil)
  endpoint = Singly::Profiles::Service.new(access_token: access_token)
  endpoint.service = service
  endpoint.delete(id)
end

#friendsObject



30
31
32
# File 'lib/singly/account.rb', line 30

def friends
  Singly::Friends.new(access_token: access_token)
end

#id(id, params = {}) ⇒ Object



34
35
36
# File 'lib/singly/account.rb', line 34

def id(id, params={})
  Singly::Id.new(params.merge(access_token: access_token, id: id))
end

#merge(source) ⇒ Object

Shortcut to Singly.auth.merge(source: <source>, dest: <dest>) where <dest> is always this account’s access_token.



52
53
54
# File 'lib/singly/account.rb', line 52

def merge(source)
  Singly.auth.merge(source: source, dest: access_token)
end

#profileObject



14
15
16
# File 'lib/singly/account.rb', line 14

def profile
  Singly::Profile.new(access_token: access_token)
end

#profiles(params = {}) ⇒ Object



18
19
20
# File 'lib/singly/account.rb', line 18

def profiles(params={})
  Singly::Profiles.new(params.merge(access_token: access_token))
end

#proxyObject



38
39
40
# File 'lib/singly/account.rb', line 38

def proxy
  Singly::Proxy.new(access_token)
end

#servicesObject



26
27
28
# File 'lib/singly/account.rb', line 26

def services
  Singly::Services.new(access_token: access_token)
end

#typesObject



22
23
24
# File 'lib/singly/account.rb', line 22

def types
  Singly::Types.new(access_token: access_token)
end