Class: Candid::ServiceLines::V2::Client
- Inherits:
-
Object
- Object
- Candid::ServiceLines::V2::Client
- Defined in:
- lib/candid/service_lines/v_2/client.rb
Instance Method Summary collapse
- #create(request_options: {}, **params) ⇒ Candid::ServiceLines::V2::Types::ServiceLine
- #create_universal(request_options: {}, **params) ⇒ Candid::ServiceLines::V2::Types::ServiceLine
- #delete(request_options: {}, **params) ⇒ untyped
- #initialize(client:) ⇒ Candid::ServiceLines::V2::Client constructor
- #update(request_options: {}, **params) ⇒ Candid::ServiceLines::V2::Types::ServiceLine
- #update_universal(request_options: {}, **params) ⇒ Candid::ServiceLines::V2::Types::ServiceLine
Constructor Details
#initialize(client:) ⇒ Candid::ServiceLines::V2::Client
8 9 10 |
# File 'lib/candid/service_lines/v_2/client.rb', line 8 def initialize(client:) @client = client end |
Instance Method Details
#create(request_options: {}, **params) ⇒ Candid::ServiceLines::V2::Types::ServiceLine
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/candid/service_lines/v_2/client.rb', line 13 def create(request_options: {}, **params) _request = Candid::Internal::JSON::Request.new( base_url: [:base_url] || Candid::Environment::PRODUCTION, method: "POST", path: "/api/service-lines/v2", body: Candid::ServiceLines::V2::Types::ServiceLineCreateStandalone.new(params).to_h ) begin _response = @client.send(_request) rescue Net::HTTPRequestTimeout raise Candid::Errors::TimeoutError end code = _response.code.to_i if code.between?(200, 299) Candid::ServiceLines::V2::Types::ServiceLine.load(_response.body) else error_class = Candid::Errors::ResponseError.subclass_for_code(code) raise error_class.new(_response.body, code: code) end end |
#create_universal(request_options: {}, **params) ⇒ Candid::ServiceLines::V2::Types::ServiceLine
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/candid/service_lines/v_2/client.rb', line 35 def create_universal(request_options: {}, **params) _request = Candid::Internal::JSON::Request.new( base_url: [:base_url] || Candid::Environment::PRODUCTION, method: "POST", path: "/api/service-lines/v2/universal", body: Candid::ServiceLines::V2::Types::UniversalServiceLineCreateStandalone.new(params).to_h ) begin _response = @client.send(_request) rescue Net::HTTPRequestTimeout raise Candid::Errors::TimeoutError end code = _response.code.to_i if code.between?(200, 299) Candid::ServiceLines::V2::Types::ServiceLine.load(_response.body) else error_class = Candid::Errors::ResponseError.subclass_for_code(code) raise error_class.new(_response.body, code: code) end end |
#delete(request_options: {}, **params) ⇒ untyped
101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 |
# File 'lib/candid/service_lines/v_2/client.rb', line 101 def delete(request_options: {}, **params) _request = Candid::Internal::JSON::Request.new( base_url: [:base_url] || Candid::Environment::PRODUCTION, method: "DELETE", path: "/api/service-lines/v2/#{params[:service_line_id]}" ) begin _response = @client.send(_request) rescue Net::HTTPRequestTimeout raise Candid::Errors::TimeoutError end code = _response.code.to_i return if code.between?(200, 299) error_class = Candid::Errors::ResponseError.subclass_for_code(code) raise error_class.new(_response.body, code: code) end |
#update(request_options: {}, **params) ⇒ Candid::ServiceLines::V2::Types::ServiceLine
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
# File 'lib/candid/service_lines/v_2/client.rb', line 79 def update(request_options: {}, **params) _request = Candid::Internal::JSON::Request.new( base_url: [:base_url] || Candid::Environment::PRODUCTION, method: "PATCH", path: "/api/service-lines/v2/#{params[:service_line_id]}", body: Candid::ServiceLines::V2::Types::ServiceLineUpdate.new(params).to_h ) begin _response = @client.send(_request) rescue Net::HTTPRequestTimeout raise Candid::Errors::TimeoutError end code = _response.code.to_i if code.between?(200, 299) Candid::ServiceLines::V2::Types::ServiceLine.load(_response.body) else error_class = Candid::Errors::ResponseError.subclass_for_code(code) raise error_class.new(_response.body, code: code) end end |
#update_universal(request_options: {}, **params) ⇒ Candid::ServiceLines::V2::Types::ServiceLine
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/candid/service_lines/v_2/client.rb', line 57 def update_universal(request_options: {}, **params) _request = Candid::Internal::JSON::Request.new( base_url: [:base_url] || Candid::Environment::PRODUCTION, method: "PATCH", path: "/api/service-lines/v2/#{params[:service_line_id]}/universal", body: Candid::ServiceLines::V2::Types::UniversalServiceLineUpdate.new(params).to_h ) begin _response = @client.send(_request) rescue Net::HTTPRequestTimeout raise Candid::Errors::TimeoutError end code = _response.code.to_i if code.between?(200, 299) Candid::ServiceLines::V2::Types::ServiceLine.load(_response.body) else error_class = Candid::Errors::ResponseError.subclass_for_code(code) raise error_class.new(_response.body, code: code) end end |