Sha256: 8fac4fde098a2dfad551681e343e79d4d9d9b278d28aaa95fffc9143c4cd13dd

Contents?: true

Size: 1.51 KB

Versions: 6

Compression:

Stored size: 1.51 KB

Contents

# typed: true
# frozen_string_literal: true

require_relative '../lib/mercadopago'

require 'minitest/autorun'

class TestCustomer < Minitest::Test
  def test_all
    sdk = Mercadopago::SDK.new('TEST-783169576377080-082620-395ee7f82e0d55b1db606c118686c1db-464842924')

    customer_object = {
      email: 'test_payer_999922@testuser.com',
      first_name: 'Rafa',
      last_name: 'Williner',
      phone: {
        area_code: '03492',
        number: '432334'
      },
      identification: {
        type: 'DNI',
        number: '29804555'
      },
      address: {
        zip_code: '2300',
        street_name: 'some street'
      },
      description: 'customer description'
    }

    begin
      customer_saved = sdk.customer.create(customer_object)
      assert_equal 201, customer_saved[:status]
      sleep(1)

      customers = sdk.customer.search(filters: { email: 'test_payer_999922@testuser.com' })
      assert_equal 200, customers[:status]
      sleep(1)

      customer_update = sdk.customer.update(customer_saved[:response]['id'], { last_name: 'Payer' })
      assert_equal 200, customer_update[:status]
      sleep(1)

      customer_updated = sdk.customer.get(customer_saved[:response]['id'])
      assert_equal 'Payer', customer_updated[:response]['last_name']
      sleep(1)
    ensure
      if customer_saved.key?(:response) && customer_saved[:response].key?('id')
        customer_deleted = sdk.customer.delete(customer_saved[:response]['id'])
        assert_equal 200, customer_deleted[:status]
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
mercadopago-sdk-2.2.1 tests/test_customer.rb
mercadopago-sdk-2.2.0 tests/test_customer.rb
mercadopago-sdk-2.1.0 tests/test_customer.rb
mercadopago-sdk-2.0.3 tests/test_customer.rb
mercadopago-sdk-2.0.2 tests/test_customer.rb
mercadopago-sdk-2.0.1 tests/test_customer.rb