Class: Rallio::Account

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

Overview

Represents an account object as it comes from Rallio.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

app_credentials

Instance Attribute Details

#cityString

Returns account city

Returns:

  • (String)

    account city


18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/rallio/account.rb', line 18

class Account < Base
  attribute :id, Integer
  attribute :name, String
  attribute :short_name, String
  attribute :url, String
  attribute :city, String
  attribute :country_code, String
  attribute :time_zone, String

  # Retreives accounts.
  #
  # @param franchisor_id [Integer] franchisor_id to get accounts for
  # @return [Array<Rallio::Account>]
  def self.for(franchisor_id:)
    response = self.get("/franchisors/#{franchisor_id}/accounts", headers: app_credentials)
    response.parsed_response['accounts'].map { |a| new a }
  end

  # Creates an account.
  #
  # @param franchisor_id [Integer] franchisor_id to create account under
  # @param payload [Hash]
  # @option payload [Hash] :account data to create account with
  # @return [Hash] hash of account created
  def self.create(franchisor_id:, payload:)
    self.post("/franchisors/#{franchisor_id}/accounts", headers: app_credentials, body: payload).parsed_response
  end

  # Retreives reviews for the account.
  #
  # @param access_token [String] user access token for API access to account
  # @return [Array<Rallio::Review>]
  def reviews(access_token:)
    Review.all(type: type, id: id, access_token: access_token)
  end

  private

  def type
    :accounts
  end
end

#country_codeString

Returns account country code

Returns:

  • (String)

    account country code


18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/rallio/account.rb', line 18

class Account < Base
  attribute :id, Integer
  attribute :name, String
  attribute :short_name, String
  attribute :url, String
  attribute :city, String
  attribute :country_code, String
  attribute :time_zone, String

  # Retreives accounts.
  #
  # @param franchisor_id [Integer] franchisor_id to get accounts for
  # @return [Array<Rallio::Account>]
  def self.for(franchisor_id:)
    response = self.get("/franchisors/#{franchisor_id}/accounts", headers: app_credentials)
    response.parsed_response['accounts'].map { |a| new a }
  end

  # Creates an account.
  #
  # @param franchisor_id [Integer] franchisor_id to create account under
  # @param payload [Hash]
  # @option payload [Hash] :account data to create account with
  # @return [Hash] hash of account created
  def self.create(franchisor_id:, payload:)
    self.post("/franchisors/#{franchisor_id}/accounts", headers: app_credentials, body: payload).parsed_response
  end

  # Retreives reviews for the account.
  #
  # @param access_token [String] user access token for API access to account
  # @return [Array<Rallio::Review>]
  def reviews(access_token:)
    Review.all(type: type, id: id, access_token: access_token)
  end

  private

  def type
    :accounts
  end
end

#idInteger

Returns unique id for account

Returns:

  • (Integer)

    unique id for account


18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/rallio/account.rb', line 18

class Account < Base
  attribute :id, Integer
  attribute :name, String
  attribute :short_name, String
  attribute :url, String
  attribute :city, String
  attribute :country_code, String
  attribute :time_zone, String

  # Retreives accounts.
  #
  # @param franchisor_id [Integer] franchisor_id to get accounts for
  # @return [Array<Rallio::Account>]
  def self.for(franchisor_id:)
    response = self.get("/franchisors/#{franchisor_id}/accounts", headers: app_credentials)
    response.parsed_response['accounts'].map { |a| new a }
  end

  # Creates an account.
  #
  # @param franchisor_id [Integer] franchisor_id to create account under
  # @param payload [Hash]
  # @option payload [Hash] :account data to create account with
  # @return [Hash] hash of account created
  def self.create(franchisor_id:, payload:)
    self.post("/franchisors/#{franchisor_id}/accounts", headers: app_credentials, body: payload).parsed_response
  end

  # Retreives reviews for the account.
  #
  # @param access_token [String] user access token for API access to account
  # @return [Array<Rallio::Review>]
  def reviews(access_token:)
    Review.all(type: type, id: id, access_token: access_token)
  end

  private

  def type
    :accounts
  end
end

#nameString

Returns account name

Returns:

  • (String)

    account name


18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/rallio/account.rb', line 18

class Account < Base
  attribute :id, Integer
  attribute :name, String
  attribute :short_name, String
  attribute :url, String
  attribute :city, String
  attribute :country_code, String
  attribute :time_zone, String

  # Retreives accounts.
  #
  # @param franchisor_id [Integer] franchisor_id to get accounts for
  # @return [Array<Rallio::Account>]
  def self.for(franchisor_id:)
    response = self.get("/franchisors/#{franchisor_id}/accounts", headers: app_credentials)
    response.parsed_response['accounts'].map { |a| new a }
  end

  # Creates an account.
  #
  # @param franchisor_id [Integer] franchisor_id to create account under
  # @param payload [Hash]
  # @option payload [Hash] :account data to create account with
  # @return [Hash] hash of account created
  def self.create(franchisor_id:, payload:)
    self.post("/franchisors/#{franchisor_id}/accounts", headers: app_credentials, body: payload).parsed_response
  end

  # Retreives reviews for the account.
  #
  # @param access_token [String] user access token for API access to account
  # @return [Array<Rallio::Review>]
  def reviews(access_token:)
    Review.all(type: type, id: id, access_token: access_token)
  end

  private

  def type
    :accounts
  end
end

#short_nameString

Returns account short name

Returns:

  • (String)

    account short name


18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/rallio/account.rb', line 18

class Account < Base
  attribute :id, Integer
  attribute :name, String
  attribute :short_name, String
  attribute :url, String
  attribute :city, String
  attribute :country_code, String
  attribute :time_zone, String

  # Retreives accounts.
  #
  # @param franchisor_id [Integer] franchisor_id to get accounts for
  # @return [Array<Rallio::Account>]
  def self.for(franchisor_id:)
    response = self.get("/franchisors/#{franchisor_id}/accounts", headers: app_credentials)
    response.parsed_response['accounts'].map { |a| new a }
  end

  # Creates an account.
  #
  # @param franchisor_id [Integer] franchisor_id to create account under
  # @param payload [Hash]
  # @option payload [Hash] :account data to create account with
  # @return [Hash] hash of account created
  def self.create(franchisor_id:, payload:)
    self.post("/franchisors/#{franchisor_id}/accounts", headers: app_credentials, body: payload).parsed_response
  end

  # Retreives reviews for the account.
  #
  # @param access_token [String] user access token for API access to account
  # @return [Array<Rallio::Review>]
  def reviews(access_token:)
    Review.all(type: type, id: id, access_token: access_token)
  end

  private

  def type
    :accounts
  end
end

#time_zoneString

Returns account time zone

Returns:

  • (String)

    account time zone


18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/rallio/account.rb', line 18

class Account < Base
  attribute :id, Integer
  attribute :name, String
  attribute :short_name, String
  attribute :url, String
  attribute :city, String
  attribute :country_code, String
  attribute :time_zone, String

  # Retreives accounts.
  #
  # @param franchisor_id [Integer] franchisor_id to get accounts for
  # @return [Array<Rallio::Account>]
  def self.for(franchisor_id:)
    response = self.get("/franchisors/#{franchisor_id}/accounts", headers: app_credentials)
    response.parsed_response['accounts'].map { |a| new a }
  end

  # Creates an account.
  #
  # @param franchisor_id [Integer] franchisor_id to create account under
  # @param payload [Hash]
  # @option payload [Hash] :account data to create account with
  # @return [Hash] hash of account created
  def self.create(franchisor_id:, payload:)
    self.post("/franchisors/#{franchisor_id}/accounts", headers: app_credentials, body: payload).parsed_response
  end

  # Retreives reviews for the account.
  #
  # @param access_token [String] user access token for API access to account
  # @return [Array<Rallio::Review>]
  def reviews(access_token:)
    Review.all(type: type, id: id, access_token: access_token)
  end

  private

  def type
    :accounts
  end
end

#urlString

Returns account url

Returns:

  • (String)

    account url


18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/rallio/account.rb', line 18

class Account < Base
  attribute :id, Integer
  attribute :name, String
  attribute :short_name, String
  attribute :url, String
  attribute :city, String
  attribute :country_code, String
  attribute :time_zone, String

  # Retreives accounts.
  #
  # @param franchisor_id [Integer] franchisor_id to get accounts for
  # @return [Array<Rallio::Account>]
  def self.for(franchisor_id:)
    response = self.get("/franchisors/#{franchisor_id}/accounts", headers: app_credentials)
    response.parsed_response['accounts'].map { |a| new a }
  end

  # Creates an account.
  #
  # @param franchisor_id [Integer] franchisor_id to create account under
  # @param payload [Hash]
  # @option payload [Hash] :account data to create account with
  # @return [Hash] hash of account created
  def self.create(franchisor_id:, payload:)
    self.post("/franchisors/#{franchisor_id}/accounts", headers: app_credentials, body: payload).parsed_response
  end

  # Retreives reviews for the account.
  #
  # @param access_token [String] user access token for API access to account
  # @return [Array<Rallio::Review>]
  def reviews(access_token:)
    Review.all(type: type, id: id, access_token: access_token)
  end

  private

  def type
    :accounts
  end
end

Class Method Details

.create(franchisor_id:, payload:) ⇒ Hash

Creates an account.

Parameters:

  • franchisor_id (Integer)

    franchisor_id to create account under

  • payload (Hash)

Options Hash (payload:):

  • :account (Hash)

    data to create account with

Returns:

  • (Hash)

    hash of account created


42
43
44
# File 'lib/rallio/account.rb', line 42

def self.create(franchisor_id:, payload:)
  self.post("/franchisors/#{franchisor_id}/accounts", headers: app_credentials, body: payload).parsed_response
end

.for(franchisor_id:) ⇒ Array<Rallio::Account>

Retreives accounts.

Parameters:

  • franchisor_id (Integer)

    franchisor_id to get accounts for

Returns:


31
32
33
34
# File 'lib/rallio/account.rb', line 31

def self.for(franchisor_id:)
  response = self.get("/franchisors/#{franchisor_id}/accounts", headers: app_credentials)
  response.parsed_response['accounts'].map { |a| new a }
end

Instance Method Details

#reviews(access_token:) ⇒ Array<Rallio::Review>

Retreives reviews for the account.

Parameters:

  • access_token (String)

    user access token for API access to account

Returns:


50
51
52
# File 'lib/rallio/account.rb', line 50

def reviews(access_token:)
  Review.all(type: type, id: id, access_token: access_token)
end