Class: Moip::Customer
- Includes:
- HTTParty, Header
- Defined in:
- lib/moip/models/customer.rb
Instance Attribute Summary collapse
- #address ⇒ Object
- #billing_info ⇒ Object
- #birthdate_day ⇒ Object
- #birthdate_month ⇒ Object
- #birthdate_year ⇒ Object
- #code ⇒ Object
- #cpf ⇒ Object
- #customers ⇒ Object
- #email ⇒ Object
- #fullname ⇒ Object
- #phone_area_code ⇒ Object
- #phone_number ⇒ Object
Instance Method Summary collapse
- #attributes ⇒ Object
-
#create ⇒ Object
metodo que envia as informações para a API do moip e cria um novo cliente see moiplabs.github.io/assinaturas-docs/api.html#criar_cliente.
- #find(code) ⇒ Object
- #load ⇒ Object
- #validates_presence_of_address ⇒ Object
- #validates_presence_of_billing_info ⇒ Object
Methods included from Header
#auth, #base_url, #default_header
Methods inherited from Model
build, #set_parameters, #to_json
Instance Attribute Details
#address ⇒ Object
7 8 9 |
# File 'lib/moip/models/customer.rb', line 7 def address @address end |
#billing_info ⇒ Object
7 8 9 |
# File 'lib/moip/models/customer.rb', line 7 def billing_info @billing_info end |
#birthdate_day ⇒ Object
7 8 9 |
# File 'lib/moip/models/customer.rb', line 7 def birthdate_day @birthdate_day end |
#birthdate_month ⇒ Object
7 8 9 |
# File 'lib/moip/models/customer.rb', line 7 def birthdate_month @birthdate_month end |
#birthdate_year ⇒ Object
7 8 9 |
# File 'lib/moip/models/customer.rb', line 7 def birthdate_year @birthdate_year end |
#code ⇒ Object
7 8 9 |
# File 'lib/moip/models/customer.rb', line 7 def code @code end |
#cpf ⇒ Object
7 8 9 |
# File 'lib/moip/models/customer.rb', line 7 def cpf @cpf end |
#customers ⇒ Object
7 8 9 |
# File 'lib/moip/models/customer.rb', line 7 def customers @customers end |
#email ⇒ Object
7 8 9 |
# File 'lib/moip/models/customer.rb', line 7 def email @email end |
#fullname ⇒ Object
7 8 9 |
# File 'lib/moip/models/customer.rb', line 7 def fullname @fullname end |
#phone_area_code ⇒ Object
7 8 9 |
# File 'lib/moip/models/customer.rb', line 7 def phone_area_code @phone_area_code end |
#phone_number ⇒ Object
7 8 9 |
# File 'lib/moip/models/customer.rb', line 7 def phone_number @phone_number end |
Instance Method Details
#attributes ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/moip/models/customer.rb', line 19 def attributes { "code" => code, "email" => email, "fullname" => fullname, "cpf" => cpf, "phone_area_code" => phone_area_code, "phone_number" => phone_number, "birthdate_day" => birthdate_day, "birthdate_month" => birthdate_month, "birthdate_year" => birthdate_year, "address" => address, "billing_info" => billing_info } end |
#create ⇒ Object
metodo que envia as informações para a API do moip e cria um novo cliente see moiplabs.github.io/assinaturas-docs/api.html#criar_cliente
93 94 95 96 97 98 99 |
# File 'lib/moip/models/customer.rb', line 93 def create if self.valid? self.class.post(base_url(:customers, :params => "new_vault=true"), default_header(self.to_json)).parsed_response else raise Exception.new "#{self.errors.first[0]} #{self.errors.first[1]}" end end |
#find(code) ⇒ Object
101 102 103 104 |
# File 'lib/moip/models/customer.rb', line 101 def find code response = self.class.get(base_url(:customers, :code => code), default_header).parsed_response self.set_parameters response unless response.nil? end |
#load ⇒ Object
86 87 88 89 |
# File 'lib/moip/models/customer.rb', line 86 def load list = self.class.get(base_url(:customers), default_header).parsed_response self.costumers = list["costumers"] end |
#validates_presence_of_address ⇒ Object
55 56 57 58 59 60 61 62 63 |
# File 'lib/moip/models/customer.rb', line 55 def validates_presence_of_address self.errors.add :address, "can't be blank" and return if @address.nil? if @address.valid? true else self.errors.add :adress, @address.errors..first end end |
#validates_presence_of_billing_info ⇒ Object
65 66 67 68 69 70 71 72 73 |
# File 'lib/moip/models/customer.rb', line 65 def validates_presence_of_billing_info self.errors.add :billing_info, "can't be blank" and return if @billing_info.nil? if @billing_info.valid? true else self.errors.add :adress, @billing_info.errors..first end end |