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


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  < 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


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  < 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


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  < 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


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  < 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


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  < 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


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  < 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


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  < 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.

Options Hash (payload:):

  • :account (Hash)

    data to create account with


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.


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.


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