Class: Launchrock::Site

Inherits:
Connection show all
Defined in:
lib/launchrock/models/site.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Connection

perform_post

Constructor Details

#initialize(client, id, name) ⇒ Site

Returns a new instance of Site.



5
6
7
# File 'lib/launchrock/models/site.rb', line 5

def initialize(client, id, name)
  self.client, self.id, self.name = client, id, name
end

Instance Attribute Details

#access_tokenObject

Returns the value of attribute access_token.



3
4
5
# File 'lib/launchrock/models/site.rb', line 3

def access_token
  @access_token
end

#clientObject

Returns the value of attribute client.



3
4
5
# File 'lib/launchrock/models/site.rb', line 3

def client
  @client
end

#idObject

Returns the value of attribute id.



3
4
5
# File 'lib/launchrock/models/site.rb', line 3

def id
  @id
end

#nameObject

Returns the value of attribute name.



3
4
5
# File 'lib/launchrock/models/site.rb', line 3

def name
  @name
end

Class Method Details

.all(client) ⇒ Object

WARNING: undocumented API



10
11
12
13
14
15
16
# File 'lib/launchrock/models/site.rb', line 10

def self.all(client)
  attributes = perform_post("/v1/getPlatformUserSites", {:user_id => client.client_id })['platform_user_sites']

  attributes.map(&:symbolize_keys).map do |attrs|
   Site.new(client, attrs[:SID], attrs[:siteName])
  end
end

.by_name(client, name) ⇒ Object

WARNING: undocumented API



19
20
21
22
23
# File 'lib/launchrock/models/site.rb', line 19

def self.by_name(client, name)
  all(client).find do |site|
    site.name == name
  end
end

Instance Method Details

#usersObject

WARNING: undocumented API



34
35
36
37
38
39
# File 'lib/launchrock/models/site.rb', line 34

def users
  resp = HTTParty.get(users_url)
  raise Launchrock::Connection::ApiError, "An error occurred while fetching the list" unless resp.success?

  CSV.parse(resp.body, :headers => true, :header_converters => :launchrock)
end