class Bitpesa::Sender
This contains the details of the sender. The first time a specific sender is used the full details should be provided. Once a sender is created and is used, the next time you MUST only send the ID of the sender. This is so we can match the same sender across multiple transactions for KYC and audit purposes. Personal Sender
Example: “`json { "country": "UG", "phone_country": "UG", "phone_number": "752403639", "email": "example@home.org", "first_name": "Johnny", "last_name": "English", "city": "Kampala", "street": "Unknown 17-3", "address_description": "Description of address", "postal_code": "798983", "birth_date": "1900-12-31", "documents": [ ], "ip": "127.0.0.1", "external_id": "806ec63a-a5a7-43cc-9d75-1ee74fbcc026", "metadata": { } } “` Business Sender
Example: “`json { "type": "business", "country": "UG", "phone_country": "UG", "phone_number": "752403639", "email": "example@home.org", "name": "MyCompany", "city": "Kampala", "street": "Unknown 17-3", "postal_code": "798983", "address_description": "Description of address", "documents": [ ], "ip": "127.0.0.1", "external_id": "806ec63a-a5a7-43cc-9d75-1ee74fbcc026", "metadata": { } } “` [Sender in the API documentation](github.com/bitpesa/api-documentation/blob/master/transaction-flow.md#sender)
Attributes
The address of the sender
Description of address
Date of birth of sender
Sender's city
Country of sender in 2-character alpha ISO 3166-2 country format
Description of the sender
Needed for KYC checks. Required to approve the sender unless KYC is waived for your account. Please send us an empty list of documents: `"documents": [ ]` in the request if KYC has been waived. If the documents already exist, please send the Document
ID eg. “`JSON "documents": [ { "id": "b6648ba3-1c7b-4f59-8580-684899c84a07" } ] “`
Email of sender
The fields that have some problems and don't pass validation
Optional ID that is supplied by partner linking it to the partner's own Sender
ID. Note: if present we will validate whether the sent ID is a duplicate in our system or not.
First name of sender (used only with a Personal sender)
IP of sender
Last name of sender (used only with a Personal sender)
Metadata of sender. You can store any detail specific to your integration here (for example the local ID of the sender on your end). When requesting sender details you will receive the sent metadata back. Also when sending sender related webhooks you will receive the details stored here as well.
Middle name of sender (used only with a Personal sender)
Name of sender (used only with a Business sender)
The nationality of the sender (used only with a Personal sender)
Occupation of sender (used only with a Personal sender)
The onboarding status of the sender
Phone country of sender in 2-character alpha ISO 3166-2 country format
Phone number of sender (without country callcode)
Zip code of sender
Sender's street
Type of sender to create - either person or business (defaults to person)
Public Class Methods
Attribute mapping from ruby-style variable name to JSON key.
# File lib/bitpesa-sdk/models/sender.rb, line 117 def self.attribute_map { :'type' => :'type', :'country' => :'country', :'phone_country' => :'phone_country', :'phone_number' => :'phone_number', :'email' => :'email', :'first_name' => :'first_name', :'middle_name' => :'middle_name', :'last_name' => :'last_name', :'occupation' => :'occupation', :'nationality' => :'nationality', :'onboarding_status' => :'onboarding_status', :'address' => :'address', :'description' => :'description', :'name' => :'name', :'city' => :'city', :'street' => :'street', :'address_description' => :'address_description', :'postal_code' => :'postal_code', :'birth_date' => :'birth_date', :'ip' => :'ip', :'documents' => :'documents', :'metadata' => :'metadata', :'state' => :'state', :'id' => :'id', :'external_id' => :'external_id', :'errors' => :'errors' } end
Initializes the object @param [Hash] attributes Model attributes in the form of hash
# File lib/bitpesa-sdk/models/sender.rb, line 182 def initialize(attributes = {}) return unless attributes.is_a?(Hash) # convert string to symbol for hash key attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v } if attributes.has_key?(:'type') self.type = attributes[:'type'] end if attributes.has_key?(:'country') self.country = attributes[:'country'] end if attributes.has_key?(:'phone_country') self.phone_country = attributes[:'phone_country'] end if attributes.has_key?(:'phone_number') self.phone_number = attributes[:'phone_number'] end if attributes.has_key?(:'email') self.email = attributes[:'email'] end if attributes.has_key?(:'first_name') self.first_name = attributes[:'first_name'] end if attributes.has_key?(:'middle_name') self.middle_name = attributes[:'middle_name'] end if attributes.has_key?(:'last_name') self.last_name = attributes[:'last_name'] end if attributes.has_key?(:'occupation') self.occupation = attributes[:'occupation'] end if attributes.has_key?(:'nationality') self.nationality = attributes[:'nationality'] end if attributes.has_key?(:'onboarding_status') self.onboarding_status = attributes[:'onboarding_status'] end if attributes.has_key?(:'address') self.address = attributes[:'address'] end if attributes.has_key?(:'description') self.description = attributes[:'description'] end if attributes.has_key?(:'name') self.name = attributes[:'name'] end if attributes.has_key?(:'city') self.city = attributes[:'city'] end if attributes.has_key?(:'street') self.street = attributes[:'street'] end if attributes.has_key?(:'address_description') self.address_description = attributes[:'address_description'] end if attributes.has_key?(:'postal_code') self.postal_code = attributes[:'postal_code'] end if attributes.has_key?(:'birth_date') self.birth_date = attributes[:'birth_date'] end if attributes.has_key?(:'ip') self.ip = attributes[:'ip'] end if attributes.has_key?(:'documents') if (value = attributes[:'documents']).is_a?(Array) self.documents = value end end if attributes.has_key?(:'metadata') self.metadata = attributes[:'metadata'] end if attributes.has_key?(:'state') self.state = attributes[:'state'] end if attributes.has_key?(:'id') self.id = attributes[:'id'] end if attributes.has_key?(:'external_id') self.external_id = attributes[:'external_id'] end if attributes.has_key?(:'errors') if (value = attributes[:'errors']).is_a?(Hash) self.errors = value end end end
Attribute type mapping.
# File lib/bitpesa-sdk/models/sender.rb, line 149 def self.openapi_types { :'type' => :'String', :'country' => :'String', :'phone_country' => :'String', :'phone_number' => :'String', :'email' => :'String', :'first_name' => :'String', :'middle_name' => :'String', :'last_name' => :'String', :'occupation' => :'String', :'nationality' => :'String', :'onboarding_status' => :'String', :'address' => :'String', :'description' => :'String', :'name' => :'String', :'city' => :'String', :'street' => :'String', :'address_description' => :'String', :'postal_code' => :'String', :'birth_date' => :'Date', :'ip' => :'String', :'documents' => :'Array<Document>', :'metadata' => :'Object', :'state' => :'SenderState', :'id' => :'String', :'external_id' => :'String', :'errors' => :'Hash<String, Array<ValidationErrorDescription>>' } end
Public Instance Methods
Checks equality by comparing each attribute. @param [Object] Object to be compared
# File lib/bitpesa-sdk/models/sender.rb, line 364 def ==(o) return true if self.equal?(o) self.class == o.class && type == o.type && country == o.country && phone_country == o.phone_country && phone_number == o.phone_number && email == o.email && first_name == o.first_name && middle_name == o.middle_name && last_name == o.last_name && occupation == o.occupation && nationality == o.nationality && onboarding_status == o.onboarding_status && address == o.address && description == o.description && name == o.name && city == o.city && street == o.street && address_description == o.address_description && postal_code == o.postal_code && birth_date == o.birth_date && ip == o.ip && documents == o.documents && metadata == o.metadata && state == o.state && id == o.id && external_id == o.external_id && errors == o.errors end
# File lib/bitpesa-sdk/models/sender.rb, line 495 def [](key) to_hash[key] end
Deserializes the data based on type @param string type Data type @param string value Value to be deserialized @return [Object] Deserialized data
# File lib/bitpesa-sdk/models/sender.rb, line 433 def _deserialize(type, value) case type.to_sym when :DateTime DateTime.parse(value) when :Date Date.parse(value) when :String value.to_s when :Integer value.to_i when :Float value.to_f when :BOOLEAN if value.to_s =~ /\A(true|t|yes|y|1)\z/i true else false end when :Object # generic object (usually a Hash), return directly value when /\AArray<(?<inner_type>.+)>\z/ inner_type = Regexp.last_match[:inner_type] value.map { |v| _deserialize(inner_type, v) } when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/ k_type = Regexp.last_match[:k_type] v_type = Regexp.last_match[:v_type] {}.tap do |hash| value.each do |k, v| hash[_deserialize(k_type, k)] = _deserialize(v_type, v) end end else # model temp_model = Bitpesa.const_get(type).new temp_model.build_from_hash(value) end end
Outputs non-array value in the form of hash For object, use to_hash. Otherwise, just return the value @param [Object] value Any valid value @return [Hash] Returns the value in the form of hash
# File lib/bitpesa-sdk/models/sender.rb, line 507 def _to_hash(value) if value.is_a?(Array) value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash value.to_hash else value end end
Builds the object from hash @param [Hash] attributes Model attributes in the form of hash @return [Object] Returns the model itself
# File lib/bitpesa-sdk/models/sender.rb, line 412 def build_from_hash(attributes) return nil unless attributes.is_a?(Hash) self.class.openapi_types.each_pair do |key, type| if type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the the attribute # is documented as an array but the input is not if attributes[self.class.attribute_map[key]].is_a?(Array) self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) }) end elsif !attributes[self.class.attribute_map[key]].nil? self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) end # or else data not found in attributes(hash), not an issue as the data can be optional end self end
# File lib/bitpesa-sdk/models/sender.rb, line 499 def dig(*args) to_hash.dig(*args) end
@see the `==` method @param [Object] Object to be compared
# File lib/bitpesa-sdk/models/sender.rb, line 397 def eql?(o) self == o end
Calculates hash code according to all attributes. @return [Fixnum] Hash code
# File lib/bitpesa-sdk/models/sender.rb, line 403 def hash [type, country, phone_country, phone_number, email, first_name, middle_name, last_name, occupation, nationality, onboarding_status, address, description, name, city, street, address_description, postal_code, birth_date, ip, documents, metadata, state, id, external_id, errors].hash end
Show invalid properties with the reasons. Usually used together with valid? @return Array for valid properties with the reasons
# File lib/bitpesa-sdk/models/sender.rb, line 299 def list_invalid_properties invalid_properties = Array.new if @country.nil? invalid_properties.push('invalid value for "country", country cannot be nil.') end if @phone_country.nil? invalid_properties.push('invalid value for "phone_country", phone_country cannot be nil.') end if @email.nil? invalid_properties.push('invalid value for "email", email cannot be nil.') end if @city.nil? invalid_properties.push('invalid value for "city", city cannot be nil.') end if @street.nil? invalid_properties.push('invalid value for "street", street cannot be nil.') end if @postal_code.nil? invalid_properties.push('invalid value for "postal_code", postal_code cannot be nil.') end if @ip.nil? invalid_properties.push('invalid value for "ip", ip cannot be nil.') end if @documents.nil? invalid_properties.push('invalid value for "documents", documents cannot be nil.') end invalid_properties end
Returns the object in the form of hash @return [Hash] Returns the object in the form of hash
# File lib/bitpesa-sdk/models/sender.rb, line 485 def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) next if value.nil? hash[param] = _to_hash(value) end ::ActiveSupport::HashWithIndifferentAccess.new(hash) end
Returns the string representation of the object @return [String] String presentation of the object
# File lib/bitpesa-sdk/models/sender.rb, line 473 def to_s to_hash.to_s end
Custom attribute writer method checking allowed values (enum). @param [Object] type Object to be assigned
# File lib/bitpesa-sdk/models/sender.rb, line 354 def type=(type) validator = EnumAttributeValidator.new('String', ['person', 'business']) unless validator.valid?(type) fail ArgumentError, 'invalid value for "type", must be one of #{validator.allowable_values}.' end @type = type end
Check to see if the all the properties in the model are valid @return true if the model is valid
# File lib/bitpesa-sdk/models/sender.rb, line 338 def valid? type_validator = EnumAttributeValidator.new('String', ['person', 'business']) return false unless type_validator.valid?(@type) return false if @country.nil? return false if @phone_country.nil? return false if @email.nil? return false if @city.nil? return false if @street.nil? return false if @postal_code.nil? return false if @ip.nil? return false if @documents.nil? true end