Class: Io::Flow::V0::Clients::DimensionEstimates

Inherits:
Object
  • Object
show all
Defined in:
lib/flow_commerce/flow_api_v0_client.rb

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ DimensionEstimates

Returns a new instance of DimensionEstimates.



3867
3868
3869
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 3867

def initialize(client)
  @client = HttpClient::Preconditions.assert_class('client', client, ::Io::Flow::V0::Client)
end

Instance Method Details

#delete_by_id(organization, id) ⇒ Object



3911
3912
3913
3914
3915
3916
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 3911

def delete_by_id(organization, id)
  HttpClient::Preconditions.assert_class('organization', organization, String)
  HttpClient::Preconditions.assert_class('id', id, String)
  r = @client.request("/#{CGI.escape(organization)}/dimension-estimates/#{CGI.escape(id)}").delete
  nil
end

#get(organization, incoming = {}) ⇒ Object



3871
3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 3871

def get(organization, incoming={})
  HttpClient::Preconditions.assert_class('organization', organization, String)
  opts = HttpClient::Helper.symbolize_keys(incoming)
  query = {
    :id => (x = opts.delete(:id); x.nil? ? nil : HttpClient::Preconditions.assert_class('id', x, Array).map { |v| HttpClient::Preconditions.assert_class('id', v, String) }),
    :limit => HttpClient::Preconditions.assert_class('limit', (x = opts.delete(:limit); x.nil? ? 25 : x), Integer),
    :offset => HttpClient::Preconditions.assert_class('offset', (x = opts.delete(:offset); x.nil? ? 0 : x), Integer),
    :sort => HttpClient::Preconditions.assert_class('sort', (x = opts.delete(:sort); x.nil? ? "-created_at" : x), String)
  }.delete_if { |k, v| v.nil? }
  r = @client.request("/#{CGI.escape(organization)}/dimension-estimates").with_query(query).get
  r.map { |x| ::Io::Flow::V0::Models::DimensionEstimate.new(x) }
end

#get_by_id(organization, id) ⇒ Object



3904
3905
3906
3907
3908
3909
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 3904

def get_by_id(organization, id)
  HttpClient::Preconditions.assert_class('organization', organization, String)
  HttpClient::Preconditions.assert_class('id', id, String)
  r = @client.request("/#{CGI.escape(organization)}/dimension-estimates/#{CGI.escape(id)}").get
  ::Io::Flow::V0::Models::DimensionEstimate.new(r)
end

#get_versions(organization, incoming = {}) ⇒ Object



3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 3891

def get_versions(organization, incoming={})
  HttpClient::Preconditions.assert_class('organization', organization, String)
  opts = HttpClient::Helper.symbolize_keys(incoming)
  query = {
    :id => (x = opts.delete(:id); x.nil? ? nil : HttpClient::Preconditions.assert_class('id', x, Array).map { |v| HttpClient::Preconditions.assert_class('id', v, String) }),
    :limit => HttpClient::Preconditions.assert_class('limit', (x = opts.delete(:limit); x.nil? ? 25 : x), Integer),
    :offset => HttpClient::Preconditions.assert_class('offset', (x = opts.delete(:offset); x.nil? ? 0 : x), Integer),
    :sort => HttpClient::Preconditions.assert_class('sort', (x = opts.delete(:sort); x.nil? ? "journal_timestamp" : x), String)
  }.delete_if { |k, v| v.nil? }
  r = @client.request("/#{CGI.escape(organization)}/dimension-estimates/versions").with_query(query).get
  r.map { |x| ::Io::Flow::V0::Models::DimensionEstimateVersion.new(x) }
end

#post(organization, dimension_estimate_form) ⇒ Object



3884
3885
3886
3887
3888
3889
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 3884

def post(organization, dimension_estimate_form)
  HttpClient::Preconditions.assert_class('organization', organization, String)
  (x = dimension_estimate_form; x.is_a?(::Io::Flow::V0::Models::DimensionEstimateForm) ? x : ::Io::Flow::V0::Models::DimensionEstimateForm.new(x))
  r = @client.request("/#{CGI.escape(organization)}/dimension-estimates").with_json(dimension_estimate_form.to_json).post
  ::Io::Flow::V0::Models::DimensionEstimate.new(r)
end