Class: CiToolkit::SeeTestClient
- Inherits:
-
Object
- Object
- CiToolkit::SeeTestClient
- Defined in:
- lib/ci_toolkit/seetest_client.rb
Overview
A client for Seetest webservice. See API doc for more info: docs.experitest.com/display/PM/How+To+Execute+Rest+API rubocop:disable Metrics/ClassLength
Constant Summary collapse
- SUCCESS =
"SUCCESS"
- OKAY =
"OK"
- ERROR =
"ERROR"
- API_VERSION =
"v1"
Instance Attribute Summary collapse
-
#faraday_conn ⇒ Object
readonly
Returns the value of attribute faraday_conn.
Instance Method Summary collapse
-
#initialize(bot = CiToolkit::SeeTestBot.new) ⇒ SeeTestClient
constructor
A new instance of SeeTestClient.
-
#upload_file(project_name:, unique_name:, full_path_to_file:, content_type: "application/octet-stream") ⇒ Object
rubocop:disable Metrics/AbcSize rubocop:disable Metrics/MethodLength.
Constructor Details
#initialize(bot = CiToolkit::SeeTestBot.new) ⇒ SeeTestClient
Returns a new instance of SeeTestClient.
18 19 20 |
# File 'lib/ci_toolkit/seetest_client.rb', line 18 def initialize(bot = CiToolkit::SeeTestBot.new) @faraday_conn = bot.faraday_conn end |
Instance Attribute Details
#faraday_conn ⇒ Object (readonly)
Returns the value of attribute faraday_conn.
16 17 18 |
# File 'lib/ci_toolkit/seetest_client.rb', line 16 def faraday_conn @faraday_conn end |
Instance Method Details
#upload_file(project_name:, unique_name:, full_path_to_file:, content_type: "application/octet-stream") ⇒ Object
rubocop:disable Metrics/AbcSize rubocop:disable Metrics/MethodLength
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/ci_toolkit/seetest_client.rb', line 24 def upload_file( project_name:, unique_name:, full_path_to_file:, content_type: "application/octet-stream" ) response = faraday_upload( project_name, unique_name, full_path_to_file, content_type ).body # Application already exists. Replace it. if response[:status] == SUCCESS && response[:data][:created] == "false" response = replace_existing_application( response[:data][:id], project_name, unique_name, full_path_to_file, content_type ) # Application with unique name already exist. Replace it. elsif response[:status] == ERROR && !response[:data].nil? && !response[:data][:uniqueName].nil? response = replace_existing_application_by_unique_name( project_name, unique_name, full_path_to_file, content_type ) end unless response[:status] == SUCCESS raise StandardError, "Upload response from Seetest returned an error. Response body is: '#{response}'" end response[:status] end |