Class: Schematic::Plangroups::Client
- Inherits:
-
Object
- Object
- Schematic::Plangroups::Client
- Defined in:
- lib/schematic/plangroups/client.rb
Instance Method Summary collapse
- #create_plan_group(request_options: {}, **params) ⇒ Schematic::Plangroups::Types::CreatePlanGroupResponse
- #get_plan_group(request_options: {}, **params) ⇒ Schematic::Plangroups::Types::GetPlanGroupResponse
- #initialize(client:) ⇒ void constructor
- #update_plan_group(request_options: {}, **params) ⇒ Schematic::Plangroups::Types::UpdatePlanGroupResponse
Constructor Details
#initialize(client:) ⇒ void
9 10 11 |
# File 'lib/schematic/plangroups/client.rb', line 9 def initialize(client:) @client = client end |
Instance Method Details
#create_plan_group(request_options: {}, **params) ⇒ Schematic::Plangroups::Types::CreatePlanGroupResponse
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/schematic/plangroups/client.rb', line 60 def create_plan_group(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-groups", body: Schematic::Plangroups::Types::CreatePlanGroupRequestBody.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::Plangroups::Types::CreatePlanGroupResponse.load(response.body) else error_class = Schematic::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |
#get_plan_group(request_options: {}, **params) ⇒ Schematic::Plangroups::Types::GetPlanGroupResponse
23 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 |
# File 'lib/schematic/plangroups/client.rb', line 23 def get_plan_group(request_options: {}, **params) params = Schematic::Internal::Types::Utils.normalize_keys(params) query_param_names = %i[include_company_counts] query_params = {} query_params["include_company_counts"] = params[:include_company_counts] if params.key?(:include_company_counts) params.except(*query_param_names) request = Schematic::Internal::JSON::Request.new( base_url: [:base_url], method: "GET", path: "plan-groups", query: query_params, 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::Plangroups::Types::GetPlanGroupResponse.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_group(request_options: {}, **params) ⇒ Schematic::Plangroups::Types::UpdatePlanGroupResponse
93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 |
# File 'lib/schematic/plangroups/client.rb', line 93 def update_plan_group(request_options: {}, **params) params = Schematic::Internal::Types::Utils.normalize_keys(params) request_data = Schematic::Plangroups::Types::UpdatePlanGroupRequestBody.new(params).to_h non_body_param_names = ["plan_group_id"] body = request_data.except(*non_body_param_names) request = Schematic::Internal::JSON::Request.new( base_url: [:base_url], method: "PUT", path: "plan-groups/#{URI.encode_uri_component(params[:plan_group_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::Plangroups::Types::UpdatePlanGroupResponse.load(response.body) else error_class = Schematic::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |