Class: Schematic::Planbundle::Client
- Inherits:
-
Object
- Object
- Schematic::Planbundle::Client
- Defined in:
- lib/schematic/planbundle/client.rb
Instance Method Summary collapse
- #create_plan_bundle(request_options: {}, **params) ⇒ Schematic::Planbundle::Types::CreatePlanBundleResponse
- #initialize(client:) ⇒ void constructor
- #update_plan_bundle(request_options: {}, **params) ⇒ Schematic::Planbundle::Types::UpdatePlanBundleResponse
Constructor Details
#initialize(client:) ⇒ void
9 10 11 |
# File 'lib/schematic/planbundle/client.rb', line 9 def initialize(client:) @client = client end |
Instance Method Details
#create_plan_bundle(request_options: {}, **params) ⇒ Schematic::Planbundle::Types::CreatePlanBundleResponse
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/schematic/planbundle/client.rb', line 22 def create_plan_bundle(request_options: {}, **params) params = Schematic::Internal::Types::Utils.normalize_keys(params) request = Schematic::Internal::JSON::Request.new( base_url: [:base_url], method: "POST", path: "plan-bundles", body: Schematic::Planbundle::Types::CreatePlanBundleRequestBody.new(params).to_h, request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Schematic::Errors::TimeoutError end code = response.code.to_i if code.between?(200, 299) Schematic::Planbundle::Types::CreatePlanBundleResponse.load(response.body) else error_class = Schematic::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |
#update_plan_bundle(request_options: {}, **params) ⇒ Schematic::Planbundle::Types::UpdatePlanBundleResponse
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/schematic/planbundle/client.rb', line 55 def update_plan_bundle(request_options: {}, **params) params = Schematic::Internal::Types::Utils.normalize_keys(params) request_data = Schematic::Planbundle::Types::UpdatePlanBundleRequestBody.new(params).to_h non_body_param_names = ["plan_bundle_id"] body = request_data.except(*non_body_param_names) request = Schematic::Internal::JSON::Request.new( base_url: [:base_url], method: "PUT", path: "plan-bundles/#{URI.encode_uri_component(params[:plan_bundle_id].to_s)}", body: body, request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Schematic::Errors::TimeoutError end code = response.code.to_i if code.between?(200, 299) Schematic::Planbundle::Types::UpdatePlanBundleResponse.load(response.body) else error_class = Schematic::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |