# Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. # typed: true # frozen_string_literal: true require 'faraday' require 'faraday/multipart' require 'sorbet-runtime' module OpenApiSDK extend T::Sig class Sync extend T::Sig sig { params(sdk_config: SDKConfiguration).void } def initialize(sdk_config) @sdk_configuration = sdk_config end sig { params(vertical: ::OpenApiSDK::Operations::Vertical).returns(::OpenApiSDK::Operations::StatusResponse) } def status(vertical) # status - Retrieve sync status of a certain vertical request = ::OpenApiSDK::Operations::StatusRequest.new( vertical: vertical ) url, params = @sdk_configuration.get_server_details base_url = Utils.template_url(url, params) url = Utils.generate_url( ::OpenApiSDK::Operations::StatusRequest, base_url, '/sync/status/{vertical}', request ) headers = {} headers['Accept'] = '*/*' headers['user-agent'] = @sdk_configuration.user_agent r = @sdk_configuration.client.get(url) do |req| req.headers = headers Utils.configure_request_security(req, @sdk_configuration.security) if !@sdk_configuration.nil? && !@sdk_configuration.security.nil? end content_type = r.headers.fetch('Content-Type', 'application/octet-stream') res = ::OpenApiSDK::Operations::StatusResponse.new( status_code: r.status, content_type: content_type, raw_response: r ) res end sig { returns(::OpenApiSDK::Operations::ResyncResponse) } def resync # resync - Resync common objects across a vertical url, params = @sdk_configuration.get_server_details base_url = Utils.template_url(url, params) url = "#{base_url}/sync/resync" headers = {} headers['Accept'] = 'application/json' headers['user-agent'] = @sdk_configuration.user_agent r = @sdk_configuration.client.post(url) do |req| req.headers = headers Utils.configure_request_security(req, @sdk_configuration.security) if !@sdk_configuration.nil? && !@sdk_configuration.security.nil? end content_type = r.headers.fetch('Content-Type', 'application/octet-stream') res = ::OpenApiSDK::Operations::ResyncResponse.new( status_code: r.status, content_type: content_type, raw_response: r ) if r.status == 201 if Utils.match_content_type(content_type, 'application/json') out = Utils.unmarshal_complex(r.env.response_body, ::OpenApiSDK::Shared::ResyncStatusDto) res.resync_status_dto = out end end res end sig { params(request: ::OpenApiSDK::Shared::UpdatePullFrequencyDto).returns(::OpenApiSDK::Operations::UpdatePullFrequencyResponse) } def update_pull_frequency(request) # update_pull_frequency - Update pull frequency for verticals url, params = @sdk_configuration.get_server_details base_url = Utils.template_url(url, params) url = "#{base_url}/sync/pull-frequencies" headers = {} req_content_type, data, form = Utils.serialize_request_body(request, :request, :json) headers['content-type'] = req_content_type raise StandardError, 'request body is required' if data.nil? && form.nil? headers['Accept'] = 'application/json' headers['user-agent'] = @sdk_configuration.user_agent r = @sdk_configuration.client.post(url) do |req| req.headers = headers Utils.configure_request_security(req, @sdk_configuration.security) if !@sdk_configuration.nil? && !@sdk_configuration.security.nil? if form req.body = Utils.encode_form(form) elsif Utils.match_content_type(req_content_type, 'application/x-www-form-urlencoded') req.body = URI.encode_www_form(data) else req.body = data end end content_type = r.headers.fetch('Content-Type', 'application/octet-stream') res = ::OpenApiSDK::Operations::UpdatePullFrequencyResponse.new( status_code: r.status, content_type: content_type, raw_response: r ) if r.status == 200 elsif r.status == 201 if Utils.match_content_type(content_type, 'application/json') out = Utils.unmarshal_complex(r.env.response_body, ::OpenApiSDK::Operations::UpdatePullFrequencyResponseBody) res.object = out end end res end sig { returns(::OpenApiSDK::Operations::GetPullFrequencyResponse) } def get_pull_frequency # get_pull_frequency - Get pull frequency for verticals url, params = @sdk_configuration.get_server_details base_url = Utils.template_url(url, params) url = "#{base_url}/sync/pull-frequencies" headers = {} headers['Accept'] = 'application/json' headers['user-agent'] = @sdk_configuration.user_agent r = @sdk_configuration.client.get(url) do |req| req.headers = headers Utils.configure_request_security(req, @sdk_configuration.security) if !@sdk_configuration.nil? && !@sdk_configuration.security.nil? end content_type = r.headers.fetch('Content-Type', 'application/octet-stream') res = ::OpenApiSDK::Operations::GetPullFrequencyResponse.new( status_code: r.status, content_type: content_type, raw_response: r ) if r.status == 200 if Utils.match_content_type(content_type, 'application/json') out = Utils.unmarshal_complex(r.env.response_body, ::OpenApiSDK::Shared::UpdatePullFrequencyDto) res.update_pull_frequency_dto = out end end res end end end