Class: ShieldPay::Company

Inherits:
Object
  • Object
show all
Extended by:
Helpers
Defined in:
lib/shieldpay/company.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Helpers

stringify_keys, stringify_keys!

Constructor Details

#initialize(attrs) ⇒ Company

Returns a new instance of Company.



36
37
38
39
40
41
42
43
# File 'lib/shieldpay/company.rb', line 36

def initialize(attrs)
  @address = attrs["Address"]
  @created_on = Time.parse(attrs["CreatedOn"])
  @email = attrs["Email"]
  @locality = attrs["Locality"]
  @name = attrs["CompanyName"]
  @post_code = attrs["PostalCode"]
end

Instance Attribute Details

#addressObject

Returns the value of attribute address.



5
6
7
# File 'lib/shieldpay/company.rb', line 5

def address
  @address
end

#country_codeObject

Returns the value of attribute country_code.



5
6
7
# File 'lib/shieldpay/company.rb', line 5

def country_code
  @country_code
end

#created_onObject

Returns the value of attribute created_on.



5
6
7
# File 'lib/shieldpay/company.rb', line 5

def created_on
  @created_on
end

#customer_keyObject

Returns the value of attribute customer_key.



5
6
7
# File 'lib/shieldpay/company.rb', line 5

def customer_key
  @customer_key
end

#emailObject

Returns the value of attribute email.



5
6
7
# File 'lib/shieldpay/company.rb', line 5

def email
  @email
end

#identifierObject

Returns the value of attribute identifier.



5
6
7
# File 'lib/shieldpay/company.rb', line 5

def identifier
  @identifier
end

#kyc_statusObject

Returns the value of attribute kyc_status.



5
6
7
# File 'lib/shieldpay/company.rb', line 5

def kyc_status
  @kyc_status
end

#localityObject

Returns the value of attribute locality.



5
6
7
# File 'lib/shieldpay/company.rb', line 5

def locality
  @locality
end

#nameObject

Returns the value of attribute name.



5
6
7
# File 'lib/shieldpay/company.rb', line 5

def name
  @name
end

#phoneObject

Returns the value of attribute phone.



5
6
7
# File 'lib/shieldpay/company.rb', line 5

def phone
  @phone
end

#post_codeObject

Returns the value of attribute post_code.



5
6
7
# File 'lib/shieldpay/company.rb', line 5

def post_code
  @post_code
end

Class Method Details

.create(params = {}) ⇒ Object

Contact Params Parameter Optional? Description country_code no The country code for this organization (i.e. GB) Defaults to ShieldPay.configuration.country_code email no Email address for contact person identifier no Company number for your region (i.e. Companies House Number) phone no Contact phone number for company



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/shieldpay/company.rb', line 16

def self.create(params={})
  stringify_keys!(params)
  params["country_code"] ||= ShieldPay.configuration.country_code
  response = Request.new.post("/Customer/CreateCompany", params)

  customer_key = response.dig("Data", "CustomerKey")
  kyc_status = nil
  if customer_key.is_a?(Hash)
    kyc_status = customer_key["KYCStatus"]
    customer_key = customer_key["CustomerKey"]
  end
  new(response["Data"]["Data"]).tap do |c|
    c.country_code = params["country_code"]
    c.customer_key = customer_key
    c.identifier = params["identifier"]
    c.kyc_status = kyc_status
    c.phone = params["phone"]
  end
end

Instance Method Details

#kyc_verified?Boolean

Returns:

  • (Boolean)


45
46
47
# File 'lib/shieldpay/company.rb', line 45

def kyc_verified?
  @kyc_status
end