Sha256: db588c4421b79e23eedb75e7f2a8f7b340b22974663c855a7699b731bfb362a3

Contents?: true

Size: 924 Bytes

Versions: 3

Compression:

Stored size: 924 Bytes

Contents

module Conekta
  module Operations
    module CreateMember
      def create_member(member, params)
        _url = [self._url, member].join('/')
        member = member.to_sym
        response = Requestor.new.request(:post, _url, params)

        if self.method(member).call and self.method(member).call.class.class_name == "ConektaObject"
          arr = []
          self.method(member).call.values.each do |_,v|
            arr << v.to_hash
          end
          arr << response
          self.method(member).call.load_from(arr)
          self.load_from
          instances = self.method(member).call
          instance = instances.last
        else
          instance = Util.types[member.to_s].new()
          instance.load_from(response)
          self.create_attr(member.to_s, instance)
          self.set_val(member.to_sym, instance)
          self.load_from
        end
        instance
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
conekta-1.0.0 lib/conekta/operations/create_member.rb
conekta-0.5.8 lib/conekta/operations/create_member.rb
conekta-0.5.7 lib/conekta/operations/create_member.rb