Sha256: a1118b81c13c9a2da6e08edab012f70b2193ec6cf3735d0240b333d6f0ebcb12

Contents?: true

Size: 1.96 KB

Versions: 22

Compression:

Stored size: 1.96 KB

Contents

require "spec_helper"
require "json"

# rubocop:disable Metrics/BlockLength

RSpec.describe "Adyen::Management OAuth Authentication", service: "Management" do
  before(:all) do
    @shared_values = {
      client: create_client(:oauth),
      service: "Management",
    }
    @auth_header = { "Authorization": "Bearer #{@shared_values[:client].oauth_token}"  }
  end

  # must be created manually because every field in the response is an array
  it "makes a companies GET call" do
    response_body = json_from_file("mocks/responses/Management/get_companies.json")

    url = @shared_values[:client].service_url(@shared_values[:service], "companies", @shared_values[:client].management.version)
    WebMock.stub_request(:get, url).
      with(
        headers: @auth_header
      ).
      to_return(
        body: response_body
      )

    result = @shared_values[:client].management.account_company_level_api.list_company_accounts()
    response_hash = result.response

    expect(result.status).
      to eq(200)
    expect(response_hash).
      to eq(JSON.parse(response_body))
    expect(response_hash).
      to be_a Adyen::HashWithAccessors
    expect(response_hash).
      to be_a_kind_of Hash
  end

  it "makes a create_store POST call" do
    request_body = JSON.parse(json_from_file("mocks/responses/LegalEntityManagement/create_business_line.json"))

    response_body = json_from_file("mocks/responses/LegalEntityManagement/create_business_line.json")

    url = @shared_values[:client].service_url(@shared_values[:service], "merchants/merchantID/stores", @shared_values[:client].management.version)
    WebMock.stub_request(:post, url).
      with(
        body: request_body,
        headers: @auth_header
      ).
      to_return(
        body: response_body
      )

    result = @shared_values[:client].management.account_store_level_api.create_store_by_merchant_id(request_body, 'merchantID')
    response_hash = result.response

      expect(result.status).
      to eq(200)
  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
adyen-ruby-api-library-10.1.2 spec/management-oauth_spec.rb
adyen-ruby-api-library-10.1.1 spec/management-oauth_spec.rb
adyen-ruby-api-library-10.1.0 spec/management-oauth_spec.rb
adyen-ruby-api-library-10.0.1 spec/management-oauth_spec.rb
adyen-ruby-api-library-10.0.0 spec/management-oauth_spec.rb
adyen-ruby-api-library-9.9.0 spec/management-oauth_spec.rb
adyen-ruby-api-library-9.8.0 spec/management-oauth_spec.rb
adyen-ruby-api-library-9.7.1 spec/management-oauth_spec.rb
adyen-ruby-api-library-9.7.0 spec/management-oauth_spec.rb
adyen-ruby-api-library-9.6.0 spec/management-oauth_spec.rb
adyen-ruby-api-library-9.5.2 spec/management-oauth_spec.rb
adyen-ruby-api-library-9.5.1 spec/management-oauth_spec.rb
adyen-ruby-api-library-9.5.0 spec/management-oauth_spec.rb
adyen-ruby-api-library-9.3.0 spec/management-oauth_spec.rb
adyen-ruby-api-library-9.2.0 spec/management-oauth_spec.rb
adyen-ruby-api-library-9.1.0 spec/management-oauth_spec.rb
adyen-ruby-api-library-9.0.0 spec/management-oauth_spec.rb
adyen-ruby-api-library-8.0.1 spec/management-oauth_spec.rb
adyen-ruby-api-library-8.0.0 spec/management-oauth_spec.rb
adyen-ruby-api-library-8.0.0.pre.beta.1 spec/management-oauth_spec.rb