Class: Conexa::Customer

Inherits:
Model show all
Defined in:
lib/conexa/resources/customer.rb

Overview

Customer resource for managing clients in Conexa

Examples:

Create a customer (Legal Person - PJ)

customer = Conexa::Customer.create(
  company_id: 3,
  name: 'Empresa ABC Ltda',
  legal_person: { cnpj: '99.557.155/0001-90' }
)

Retrieve a customer

customer = Conexa::Customer.find(127)
customer.name  # => "Empresa ABC Ltda"

List customers

customers = Conexa::Customer.all(company_id: [3], is_active: true)

Constant Summary

Constants inherited from ConexaObject

Conexa::ConexaObject::RESOURCES

Instance Attribute Summary collapse

Attributes inherited from ConexaObject

#attributes

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Model

all, #class_name, class_name, #create, create, #destroy, destroy, extract_page_size_or_params, #fetch, find_by, find_by_id, #id, #primary_key, primary_key_attribute, #primary_key_name, #save, #set_primary_key, show_url, underscored_class_name, url

Methods inherited from ConexaObject

#==, #[]=, convert, #empty?, #initialize, #respond_to_missing?, #to_hash, #unsaved_attributes

Constructor Details

This class inherits a constructor from Conexa::ConexaObject

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Conexa::ConexaObject

Instance Attribute Details

#company_idInteger (readonly)

Returns Company/Unit ID.

Returns:

  • (Integer)

    Company/Unit ID



45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
# File 'lib/conexa/resources/customer.rb', line 45

class Customer < Model
  primary_key_attribute :customer_id

  # @return [Array<String>] Phone numbers (empty array if null)
  def phones
    @attributes['phones'] || []
  end

  # @return [Array<String>] Message emails (empty array if null)
  def emails_message
    @attributes['emails_message'] || []
  end

  # @return [Array<String>] Financial emails (empty array if null)
  def emails_financial_messages
    @attributes['emails_financial_messages'] || []
  end

  # @return [Array<Integer>] Tag IDs (empty array if null)
  def tags_id
    @attributes['tags_id'] || []
  end

  # @return [Address, nil] Customer address
  def address
    return nil unless @attributes['address']
    Address.new(@attributes['address'])
  end

  # List persons (requesters) for this customer
  # @return [Result] List of persons
  def persons
    Conexa::Person.all(customer_id: id, limit: 100)
  end

  # List contracts for this customer
  # @return [Result] List of contracts
  def contracts
    Conexa::Contract.all(customer_id: [id], limit: 100)
  end

  # List charges for this customer
  # @return [Result] List of charges
  def charges
    Conexa::Charge.all(customer_id: [id], limit: 100)
  end

  class << self
    # List persons (requesters) for a customer without fetching the customer first
    # @param customer_id [Integer] Customer ID
    # @return [Result] List of persons
    def persons(customer_id)
      Conexa::Person.all(customer_id: customer_id, limit: 100)
    end

    # List contracts for a customer without fetching the customer first
    # @param customer_id [Integer] Customer ID
    # @return [Result] List of contracts
    def contracts(customer_id)
      Conexa::Contract.all(customer_id: [customer_id], limit: 100)
    end

    # List charges for a customer without fetching the customer first
    # @param customer_id [Integer] Customer ID
    # @return [Result] List of charges
    def charges(customer_id)
      Conexa::Charge.all(customer_id: [customer_id], limit: 100)
    end
  end
end

#created_atString? (readonly)

Returns Created at timestamp (W3C format).

Returns:

  • (String, nil)

    Created at timestamp (W3C format)



45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
# File 'lib/conexa/resources/customer.rb', line 45

class Customer < Model
  primary_key_attribute :customer_id

  # @return [Array<String>] Phone numbers (empty array if null)
  def phones
    @attributes['phones'] || []
  end

  # @return [Array<String>] Message emails (empty array if null)
  def emails_message
    @attributes['emails_message'] || []
  end

  # @return [Array<String>] Financial emails (empty array if null)
  def emails_financial_messages
    @attributes['emails_financial_messages'] || []
  end

  # @return [Array<Integer>] Tag IDs (empty array if null)
  def tags_id
    @attributes['tags_id'] || []
  end

  # @return [Address, nil] Customer address
  def address
    return nil unless @attributes['address']
    Address.new(@attributes['address'])
  end

  # List persons (requesters) for this customer
  # @return [Result] List of persons
  def persons
    Conexa::Person.all(customer_id: id, limit: 100)
  end

  # List contracts for this customer
  # @return [Result] List of contracts
  def contracts
    Conexa::Contract.all(customer_id: [id], limit: 100)
  end

  # List charges for this customer
  # @return [Result] List of charges
  def charges
    Conexa::Charge.all(customer_id: [id], limit: 100)
  end

  class << self
    # List persons (requesters) for a customer without fetching the customer first
    # @param customer_id [Integer] Customer ID
    # @return [Result] List of persons
    def persons(customer_id)
      Conexa::Person.all(customer_id: customer_id, limit: 100)
    end

    # List contracts for a customer without fetching the customer first
    # @param customer_id [Integer] Customer ID
    # @return [Result] List of contracts
    def contracts(customer_id)
      Conexa::Contract.all(customer_id: [customer_id], limit: 100)
    end

    # List charges for a customer without fetching the customer first
    # @param customer_id [Integer] Customer ID
    # @return [Result] List of charges
    def charges(customer_id)
      Conexa::Charge.all(customer_id: [customer_id], limit: 100)
    end
  end
end

#customer_idInteger (readonly)

Returns Customer ID (also accessible as #id).

Returns:

  • (Integer)

    Customer ID (also accessible as #id)



45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
# File 'lib/conexa/resources/customer.rb', line 45

class Customer < Model
  primary_key_attribute :customer_id

  # @return [Array<String>] Phone numbers (empty array if null)
  def phones
    @attributes['phones'] || []
  end

  # @return [Array<String>] Message emails (empty array if null)
  def emails_message
    @attributes['emails_message'] || []
  end

  # @return [Array<String>] Financial emails (empty array if null)
  def emails_financial_messages
    @attributes['emails_financial_messages'] || []
  end

  # @return [Array<Integer>] Tag IDs (empty array if null)
  def tags_id
    @attributes['tags_id'] || []
  end

  # @return [Address, nil] Customer address
  def address
    return nil unless @attributes['address']
    Address.new(@attributes['address'])
  end

  # List persons (requesters) for this customer
  # @return [Result] List of persons
  def persons
    Conexa::Person.all(customer_id: id, limit: 100)
  end

  # List contracts for this customer
  # @return [Result] List of contracts
  def contracts
    Conexa::Contract.all(customer_id: [id], limit: 100)
  end

  # List charges for this customer
  # @return [Result] List of charges
  def charges
    Conexa::Charge.all(customer_id: [id], limit: 100)
  end

  class << self
    # List persons (requesters) for a customer without fetching the customer first
    # @param customer_id [Integer] Customer ID
    # @return [Result] List of persons
    def persons(customer_id)
      Conexa::Person.all(customer_id: customer_id, limit: 100)
    end

    # List contracts for a customer without fetching the customer first
    # @param customer_id [Integer] Customer ID
    # @return [Result] List of contracts
    def contracts(customer_id)
      Conexa::Contract.all(customer_id: [customer_id], limit: 100)
    end

    # List charges for a customer without fetching the customer first
    # @param customer_id [Integer] Customer ID
    # @return [Result] List of charges
    def charges(customer_id)
      Conexa::Charge.all(customer_id: [customer_id], limit: 100)
    end
  end
end

#has_login_accessBoolean (readonly)

Returns Whether customer has login access.

Returns:

  • (Boolean)

    Whether customer has login access



45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
# File 'lib/conexa/resources/customer.rb', line 45

class Customer < Model
  primary_key_attribute :customer_id

  # @return [Array<String>] Phone numbers (empty array if null)
  def phones
    @attributes['phones'] || []
  end

  # @return [Array<String>] Message emails (empty array if null)
  def emails_message
    @attributes['emails_message'] || []
  end

  # @return [Array<String>] Financial emails (empty array if null)
  def emails_financial_messages
    @attributes['emails_financial_messages'] || []
  end

  # @return [Array<Integer>] Tag IDs (empty array if null)
  def tags_id
    @attributes['tags_id'] || []
  end

  # @return [Address, nil] Customer address
  def address
    return nil unless @attributes['address']
    Address.new(@attributes['address'])
  end

  # List persons (requesters) for this customer
  # @return [Result] List of persons
  def persons
    Conexa::Person.all(customer_id: id, limit: 100)
  end

  # List contracts for this customer
  # @return [Result] List of contracts
  def contracts
    Conexa::Contract.all(customer_id: [id], limit: 100)
  end

  # List charges for this customer
  # @return [Result] List of charges
  def charges
    Conexa::Charge.all(customer_id: [id], limit: 100)
  end

  class << self
    # List persons (requesters) for a customer without fetching the customer first
    # @param customer_id [Integer] Customer ID
    # @return [Result] List of persons
    def persons(customer_id)
      Conexa::Person.all(customer_id: customer_id, limit: 100)
    end

    # List contracts for a customer without fetching the customer first
    # @param customer_id [Integer] Customer ID
    # @return [Result] List of contracts
    def contracts(customer_id)
      Conexa::Contract.all(customer_id: [customer_id], limit: 100)
    end

    # List charges for a customer without fetching the customer first
    # @param customer_id [Integer] Customer ID
    # @return [Result] List of charges
    def charges(customer_id)
      Conexa::Charge.all(customer_id: [customer_id], limit: 100)
    end
  end
end

#is_activeBoolean (readonly)

Returns Whether customer is active.

Returns:

  • (Boolean)

    Whether customer is active



45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
# File 'lib/conexa/resources/customer.rb', line 45

class Customer < Model
  primary_key_attribute :customer_id

  # @return [Array<String>] Phone numbers (empty array if null)
  def phones
    @attributes['phones'] || []
  end

  # @return [Array<String>] Message emails (empty array if null)
  def emails_message
    @attributes['emails_message'] || []
  end

  # @return [Array<String>] Financial emails (empty array if null)
  def emails_financial_messages
    @attributes['emails_financial_messages'] || []
  end

  # @return [Array<Integer>] Tag IDs (empty array if null)
  def tags_id
    @attributes['tags_id'] || []
  end

  # @return [Address, nil] Customer address
  def address
    return nil unless @attributes['address']
    Address.new(@attributes['address'])
  end

  # List persons (requesters) for this customer
  # @return [Result] List of persons
  def persons
    Conexa::Person.all(customer_id: id, limit: 100)
  end

  # List contracts for this customer
  # @return [Result] List of contracts
  def contracts
    Conexa::Contract.all(customer_id: [id], limit: 100)
  end

  # List charges for this customer
  # @return [Result] List of charges
  def charges
    Conexa::Charge.all(customer_id: [id], limit: 100)
  end

  class << self
    # List persons (requesters) for a customer without fetching the customer first
    # @param customer_id [Integer] Customer ID
    # @return [Result] List of persons
    def persons(customer_id)
      Conexa::Person.all(customer_id: customer_id, limit: 100)
    end

    # List contracts for a customer without fetching the customer first
    # @param customer_id [Integer] Customer ID
    # @return [Result] List of contracts
    def contracts(customer_id)
      Conexa::Contract.all(customer_id: [customer_id], limit: 100)
    end

    # List charges for a customer without fetching the customer first
    # @param customer_id [Integer] Customer ID
    # @return [Result] List of charges
    def charges(customer_id)
      Conexa::Charge.all(customer_id: [customer_id], limit: 100)
    end
  end
end

#is_blockedBoolean (readonly)

Returns Whether customer is blocked.

Returns:

  • (Boolean)

    Whether customer is blocked



45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
# File 'lib/conexa/resources/customer.rb', line 45

class Customer < Model
  primary_key_attribute :customer_id

  # @return [Array<String>] Phone numbers (empty array if null)
  def phones
    @attributes['phones'] || []
  end

  # @return [Array<String>] Message emails (empty array if null)
  def emails_message
    @attributes['emails_message'] || []
  end

  # @return [Array<String>] Financial emails (empty array if null)
  def emails_financial_messages
    @attributes['emails_financial_messages'] || []
  end

  # @return [Array<Integer>] Tag IDs (empty array if null)
  def tags_id
    @attributes['tags_id'] || []
  end

  # @return [Address, nil] Customer address
  def address
    return nil unless @attributes['address']
    Address.new(@attributes['address'])
  end

  # List persons (requesters) for this customer
  # @return [Result] List of persons
  def persons
    Conexa::Person.all(customer_id: id, limit: 100)
  end

  # List contracts for this customer
  # @return [Result] List of contracts
  def contracts
    Conexa::Contract.all(customer_id: [id], limit: 100)
  end

  # List charges for this customer
  # @return [Result] List of charges
  def charges
    Conexa::Charge.all(customer_id: [id], limit: 100)
  end

  class << self
    # List persons (requesters) for a customer without fetching the customer first
    # @param customer_id [Integer] Customer ID
    # @return [Result] List of persons
    def persons(customer_id)
      Conexa::Person.all(customer_id: customer_id, limit: 100)
    end

    # List contracts for a customer without fetching the customer first
    # @param customer_id [Integer] Customer ID
    # @return [Result] List of contracts
    def contracts(customer_id)
      Conexa::Contract.all(customer_id: [customer_id], limit: 100)
    end

    # List charges for a customer without fetching the customer first
    # @param customer_id [Integer] Customer ID
    # @return [Result] List of charges
    def charges(customer_id)
      Conexa::Charge.all(customer_id: [customer_id], limit: 100)
    end
  end
end

#is_foreignBoolean (readonly)

Returns Whether customer is a foreigner.

Returns:

  • (Boolean)

    Whether customer is a foreigner



45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
# File 'lib/conexa/resources/customer.rb', line 45

class Customer < Model
  primary_key_attribute :customer_id

  # @return [Array<String>] Phone numbers (empty array if null)
  def phones
    @attributes['phones'] || []
  end

  # @return [Array<String>] Message emails (empty array if null)
  def emails_message
    @attributes['emails_message'] || []
  end

  # @return [Array<String>] Financial emails (empty array if null)
  def emails_financial_messages
    @attributes['emails_financial_messages'] || []
  end

  # @return [Array<Integer>] Tag IDs (empty array if null)
  def tags_id
    @attributes['tags_id'] || []
  end

  # @return [Address, nil] Customer address
  def address
    return nil unless @attributes['address']
    Address.new(@attributes['address'])
  end

  # List persons (requesters) for this customer
  # @return [Result] List of persons
  def persons
    Conexa::Person.all(customer_id: id, limit: 100)
  end

  # List contracts for this customer
  # @return [Result] List of contracts
  def contracts
    Conexa::Contract.all(customer_id: [id], limit: 100)
  end

  # List charges for this customer
  # @return [Result] List of charges
  def charges
    Conexa::Charge.all(customer_id: [id], limit: 100)
  end

  class << self
    # List persons (requesters) for a customer without fetching the customer first
    # @param customer_id [Integer] Customer ID
    # @return [Result] List of persons
    def persons(customer_id)
      Conexa::Person.all(customer_id: customer_id, limit: 100)
    end

    # List contracts for a customer without fetching the customer first
    # @param customer_id [Integer] Customer ID
    # @return [Result] List of contracts
    def contracts(customer_id)
      Conexa::Contract.all(customer_id: [customer_id], limit: 100)
    end

    # List charges for a customer without fetching the customer first
    # @param customer_id [Integer] Customer ID
    # @return [Result] List of charges
    def charges(customer_id)
      Conexa::Charge.all(customer_id: [customer_id], limit: 100)
    end
  end
end

#is_juridical_personBoolean (readonly)

Returns Whether customer is a legal person (PJ).

Returns:

  • (Boolean)

    Whether customer is a legal person (PJ)



45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
# File 'lib/conexa/resources/customer.rb', line 45

class Customer < Model
  primary_key_attribute :customer_id

  # @return [Array<String>] Phone numbers (empty array if null)
  def phones
    @attributes['phones'] || []
  end

  # @return [Array<String>] Message emails (empty array if null)
  def emails_message
    @attributes['emails_message'] || []
  end

  # @return [Array<String>] Financial emails (empty array if null)
  def emails_financial_messages
    @attributes['emails_financial_messages'] || []
  end

  # @return [Array<Integer>] Tag IDs (empty array if null)
  def tags_id
    @attributes['tags_id'] || []
  end

  # @return [Address, nil] Customer address
  def address
    return nil unless @attributes['address']
    Address.new(@attributes['address'])
  end

  # List persons (requesters) for this customer
  # @return [Result] List of persons
  def persons
    Conexa::Person.all(customer_id: id, limit: 100)
  end

  # List contracts for this customer
  # @return [Result] List of contracts
  def contracts
    Conexa::Contract.all(customer_id: [id], limit: 100)
  end

  # List charges for this customer
  # @return [Result] List of charges
  def charges
    Conexa::Charge.all(customer_id: [id], limit: 100)
  end

  class << self
    # List persons (requesters) for a customer without fetching the customer first
    # @param customer_id [Integer] Customer ID
    # @return [Result] List of persons
    def persons(customer_id)
      Conexa::Person.all(customer_id: customer_id, limit: 100)
    end

    # List contracts for a customer without fetching the customer first
    # @param customer_id [Integer] Customer ID
    # @return [Result] List of contracts
    def contracts(customer_id)
      Conexa::Contract.all(customer_id: [customer_id], limit: 100)
    end

    # List charges for a customer without fetching the customer first
    # @param customer_id [Integer] Customer ID
    # @return [Result] List of charges
    def charges(customer_id)
      Conexa::Charge.all(customer_id: [customer_id], limit: 100)
    end
  end
end

Returns Legal person data (cnpj, foundation_date, etc.).

Returns:

  • (Hash, nil)

    Legal person data (cnpj, foundation_date, etc.)



45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
# File 'lib/conexa/resources/customer.rb', line 45

class Customer < Model
  primary_key_attribute :customer_id

  # @return [Array<String>] Phone numbers (empty array if null)
  def phones
    @attributes['phones'] || []
  end

  # @return [Array<String>] Message emails (empty array if null)
  def emails_message
    @attributes['emails_message'] || []
  end

  # @return [Array<String>] Financial emails (empty array if null)
  def emails_financial_messages
    @attributes['emails_financial_messages'] || []
  end

  # @return [Array<Integer>] Tag IDs (empty array if null)
  def tags_id
    @attributes['tags_id'] || []
  end

  # @return [Address, nil] Customer address
  def address
    return nil unless @attributes['address']
    Address.new(@attributes['address'])
  end

  # List persons (requesters) for this customer
  # @return [Result] List of persons
  def persons
    Conexa::Person.all(customer_id: id, limit: 100)
  end

  # List contracts for this customer
  # @return [Result] List of contracts
  def contracts
    Conexa::Contract.all(customer_id: [id], limit: 100)
  end

  # List charges for this customer
  # @return [Result] List of charges
  def charges
    Conexa::Charge.all(customer_id: [id], limit: 100)
  end

  class << self
    # List persons (requesters) for a customer without fetching the customer first
    # @param customer_id [Integer] Customer ID
    # @return [Result] List of persons
    def persons(customer_id)
      Conexa::Person.all(customer_id: customer_id, limit: 100)
    end

    # List contracts for a customer without fetching the customer first
    # @param customer_id [Integer] Customer ID
    # @return [Result] List of contracts
    def contracts(customer_id)
      Conexa::Contract.all(customer_id: [customer_id], limit: 100)
    end

    # List charges for a customer without fetching the customer first
    # @param customer_id [Integer] Customer ID
    # @return [Result] List of charges
    def charges(customer_id)
      Conexa::Charge.all(customer_id: [customer_id], limit: 100)
    end
  end
end

#nameString (readonly)

Returns Customer name.

Returns:

  • (String)

    Customer name



45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
# File 'lib/conexa/resources/customer.rb', line 45

class Customer < Model
  primary_key_attribute :customer_id

  # @return [Array<String>] Phone numbers (empty array if null)
  def phones
    @attributes['phones'] || []
  end

  # @return [Array<String>] Message emails (empty array if null)
  def emails_message
    @attributes['emails_message'] || []
  end

  # @return [Array<String>] Financial emails (empty array if null)
  def emails_financial_messages
    @attributes['emails_financial_messages'] || []
  end

  # @return [Array<Integer>] Tag IDs (empty array if null)
  def tags_id
    @attributes['tags_id'] || []
  end

  # @return [Address, nil] Customer address
  def address
    return nil unless @attributes['address']
    Address.new(@attributes['address'])
  end

  # List persons (requesters) for this customer
  # @return [Result] List of persons
  def persons
    Conexa::Person.all(customer_id: id, limit: 100)
  end

  # List contracts for this customer
  # @return [Result] List of contracts
  def contracts
    Conexa::Contract.all(customer_id: [id], limit: 100)
  end

  # List charges for this customer
  # @return [Result] List of charges
  def charges
    Conexa::Charge.all(customer_id: [id], limit: 100)
  end

  class << self
    # List persons (requesters) for a customer without fetching the customer first
    # @param customer_id [Integer] Customer ID
    # @return [Result] List of persons
    def persons(customer_id)
      Conexa::Person.all(customer_id: customer_id, limit: 100)
    end

    # List contracts for a customer without fetching the customer first
    # @param customer_id [Integer] Customer ID
    # @return [Result] List of contracts
    def contracts(customer_id)
      Conexa::Contract.all(customer_id: [customer_id], limit: 100)
    end

    # List charges for a customer without fetching the customer first
    # @param customer_id [Integer] Customer ID
    # @return [Result] List of charges
    def charges(customer_id)
      Conexa::Charge.all(customer_id: [customer_id], limit: 100)
    end
  end
end

#natural_personHash? (readonly)

Returns Natural person data (cpf, birth_date, etc.).

Returns:

  • (Hash, nil)

    Natural person data (cpf, birth_date, etc.)



45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
# File 'lib/conexa/resources/customer.rb', line 45

class Customer < Model
  primary_key_attribute :customer_id

  # @return [Array<String>] Phone numbers (empty array if null)
  def phones
    @attributes['phones'] || []
  end

  # @return [Array<String>] Message emails (empty array if null)
  def emails_message
    @attributes['emails_message'] || []
  end

  # @return [Array<String>] Financial emails (empty array if null)
  def emails_financial_messages
    @attributes['emails_financial_messages'] || []
  end

  # @return [Array<Integer>] Tag IDs (empty array if null)
  def tags_id
    @attributes['tags_id'] || []
  end

  # @return [Address, nil] Customer address
  def address
    return nil unless @attributes['address']
    Address.new(@attributes['address'])
  end

  # List persons (requesters) for this customer
  # @return [Result] List of persons
  def persons
    Conexa::Person.all(customer_id: id, limit: 100)
  end

  # List contracts for this customer
  # @return [Result] List of contracts
  def contracts
    Conexa::Contract.all(customer_id: [id], limit: 100)
  end

  # List charges for this customer
  # @return [Result] List of charges
  def charges
    Conexa::Charge.all(customer_id: [id], limit: 100)
  end

  class << self
    # List persons (requesters) for a customer without fetching the customer first
    # @param customer_id [Integer] Customer ID
    # @return [Result] List of persons
    def persons(customer_id)
      Conexa::Person.all(customer_id: customer_id, limit: 100)
    end

    # List contracts for a customer without fetching the customer first
    # @param customer_id [Integer] Customer ID
    # @return [Result] List of contracts
    def contracts(customer_id)
      Conexa::Contract.all(customer_id: [customer_id], limit: 100)
    end

    # List charges for a customer without fetching the customer first
    # @param customer_id [Integer] Customer ID
    # @return [Result] List of charges
    def charges(customer_id)
      Conexa::Charge.all(customer_id: [customer_id], limit: 100)
    end
  end
end

#trade_nameString? (readonly)

Returns Trade name.

Returns:

  • (String, nil)

    Trade name



45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
# File 'lib/conexa/resources/customer.rb', line 45

class Customer < Model
  primary_key_attribute :customer_id

  # @return [Array<String>] Phone numbers (empty array if null)
  def phones
    @attributes['phones'] || []
  end

  # @return [Array<String>] Message emails (empty array if null)
  def emails_message
    @attributes['emails_message'] || []
  end

  # @return [Array<String>] Financial emails (empty array if null)
  def emails_financial_messages
    @attributes['emails_financial_messages'] || []
  end

  # @return [Array<Integer>] Tag IDs (empty array if null)
  def tags_id
    @attributes['tags_id'] || []
  end

  # @return [Address, nil] Customer address
  def address
    return nil unless @attributes['address']
    Address.new(@attributes['address'])
  end

  # List persons (requesters) for this customer
  # @return [Result] List of persons
  def persons
    Conexa::Person.all(customer_id: id, limit: 100)
  end

  # List contracts for this customer
  # @return [Result] List of contracts
  def contracts
    Conexa::Contract.all(customer_id: [id], limit: 100)
  end

  # List charges for this customer
  # @return [Result] List of charges
  def charges
    Conexa::Charge.all(customer_id: [id], limit: 100)
  end

  class << self
    # List persons (requesters) for a customer without fetching the customer first
    # @param customer_id [Integer] Customer ID
    # @return [Result] List of persons
    def persons(customer_id)
      Conexa::Person.all(customer_id: customer_id, limit: 100)
    end

    # List contracts for a customer without fetching the customer first
    # @param customer_id [Integer] Customer ID
    # @return [Result] List of contracts
    def contracts(customer_id)
      Conexa::Contract.all(customer_id: [customer_id], limit: 100)
    end

    # List charges for a customer without fetching the customer first
    # @param customer_id [Integer] Customer ID
    # @return [Result] List of charges
    def charges(customer_id)
      Conexa::Charge.all(customer_id: [customer_id], limit: 100)
    end
  end
end

Class Method Details

.charges(customer_id) ⇒ Result

List charges for a customer without fetching the customer first

Parameters:

  • customer_id (Integer)

    Customer ID

Returns:

  • (Result)

    List of charges



110
111
112
# File 'lib/conexa/resources/customer.rb', line 110

def charges(customer_id)
  Conexa::Charge.all(customer_id: [customer_id], limit: 100)
end

.contracts(customer_id) ⇒ Result

List contracts for a customer without fetching the customer first

Parameters:

  • customer_id (Integer)

    Customer ID

Returns:

  • (Result)

    List of contracts



103
104
105
# File 'lib/conexa/resources/customer.rb', line 103

def contracts(customer_id)
  Conexa::Contract.all(customer_id: [customer_id], limit: 100)
end

.persons(customer_id) ⇒ Result

List persons (requesters) for a customer without fetching the customer first

Parameters:

  • customer_id (Integer)

    Customer ID

Returns:

  • (Result)

    List of persons



96
97
98
# File 'lib/conexa/resources/customer.rb', line 96

def persons(customer_id)
  Conexa::Person.all(customer_id: customer_id, limit: 100)
end

Instance Method Details

#addressAddress?

Returns Customer address.

Returns:

  • (Address, nil)

    Customer address



69
70
71
72
# File 'lib/conexa/resources/customer.rb', line 69

def address
  return nil unless @attributes['address']
  Address.new(@attributes['address'])
end

#chargesResult

List charges for this customer

Returns:

  • (Result)

    List of charges



88
89
90
# File 'lib/conexa/resources/customer.rb', line 88

def charges
  Conexa::Charge.all(customer_id: [id], limit: 100)
end

#contractsResult

List contracts for this customer

Returns:

  • (Result)

    List of contracts



82
83
84
# File 'lib/conexa/resources/customer.rb', line 82

def contracts
  Conexa::Contract.all(customer_id: [id], limit: 100)
end

#emails_financial_messagesArray<String>

Returns Financial emails (empty array if null).

Returns:

  • (Array<String>)

    Financial emails (empty array if null)



59
60
61
# File 'lib/conexa/resources/customer.rb', line 59

def emails_financial_messages
  @attributes['emails_financial_messages'] || []
end

#emails_messageArray<String>

Returns Message emails (empty array if null).

Returns:

  • (Array<String>)

    Message emails (empty array if null)



54
55
56
# File 'lib/conexa/resources/customer.rb', line 54

def emails_message
  @attributes['emails_message'] || []
end

#personsResult

List persons (requesters) for this customer

Returns:

  • (Result)

    List of persons



76
77
78
# File 'lib/conexa/resources/customer.rb', line 76

def persons
  Conexa::Person.all(customer_id: id, limit: 100)
end

#phonesArray<String>

Returns Phone numbers (empty array if null).

Returns:

  • (Array<String>)

    Phone numbers (empty array if null)



49
50
51
# File 'lib/conexa/resources/customer.rb', line 49

def phones
  @attributes['phones'] || []
end

#tags_idArray<Integer>

Returns Tag IDs (empty array if null).

Returns:

  • (Array<Integer>)

    Tag IDs (empty array if null)



64
65
66
# File 'lib/conexa/resources/customer.rb', line 64

def tags_id
  @attributes['tags_id'] || []
end