Class: Schematic::Planbundle::Client
- Inherits:
-
Object
- Object
- Schematic::Planbundle::Client
- Defined in:
- lib/schematic/planbundle/client.rb
Instance Method Summary collapse
- #create_custom_plan_bundle(request_options: {}, **params) ⇒ Schematic::Planbundle::Types::CreateCustomPlanBundleResponse
- #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_custom_plan_bundle(request_options: {}, **params) ⇒ Schematic::Planbundle::Types::CreateCustomPlanBundleResponse
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/schematic/planbundle/client.rb', line 37 def create_custom_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: "custom-plan-bundles", body: Schematic::Planbundle::Types::CreateCustomPlanBundleRequestBody.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::CreateCustomPlanBundleResponse.load(response.body) else error_class = Schematic::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |
#create_plan_bundle(request_options: {}, **params) ⇒ Schematic::Planbundle::Types::CreatePlanBundleResponse
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 |
# File 'lib/schematic/planbundle/client.rb', line 80 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
124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 |
# File 'lib/schematic/planbundle/client.rb', line 124 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 = %w[plan_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_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 |