Class: Xplenty::Kensa::DeprovisionCheck

Inherits:
ApiCheck show all
Includes:
HTTP
Defined in:
lib/xplenty/kensa/check.rb

Instance Attribute Summary

Attributes inherited from Check

#data, #screen

Instance Method Summary collapse

Methods included from HTTP

#delete, #get, #post, #put, #request

Methods inherited from ApiCheck

#base_path, #credentials, #xplenty_id

Methods inherited from Check

#call, #check, #env, #error, #initialize, #run, #test, #to_proc, #url

Constructor Details

This class inherits a constructor from Xplenty::Kensa::Check

Instance Method Details

#call!Object

Raises:

  • (ArgumentError)


341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
# File 'lib/xplenty/kensa/check.rb', line 341

def call!
  id = data[:id]
  raise ArgumentError, "No id specified" if id.nil?

  path = "#{base_path}/#{CGI::escape(id.to_s)}"

  test "DELETE #{path}"
  check "response" do
    code, _ = delete(credentials, path, nil)
    if code == 200
      true
    elsif code == -1
      error("unable to connect to #{url}")
    else
      error("expected 200, got #{code}")
    end
  end

  check "authentication" do
    wrong_credentials = ['wrong', 'secret']
    code, _ = delete(wrong_credentials, path, nil)
    error("expected 401, got #{code}") if code != 401
    true
  end

end