Class: Io::Flow::V0::Clients::ShippingNotifications

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

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ ShippingNotifications

Returns a new instance of ShippingNotifications.



3037
3038
3039
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 3037

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

Instance Method Details

#delete_by_key(organization, key) ⇒ Object



3081
3082
3083
3084
3085
3086
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 3081

def delete_by_key(organization, key)
  HttpClient::Preconditions.assert_class('organization', organization, String)
  HttpClient::Preconditions.assert_class('key', key, String)
  r = @client.request("/#{CGI.escape(organization)}/shipping-notifications/#{CGI.escape(key)}").delete
  nil
end

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



3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 3041

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) }),
    :key => (x = opts.delete(:key); x.nil? ? nil : HttpClient::Preconditions.assert_class('key', x, Array).map { |v| HttpClient::Preconditions.assert_class('key', v, String) }),
    :carrier_tracking_number => (x = opts.delete(:carrier_tracking_number); x.nil? ? nil : HttpClient::Preconditions.assert_class('carrier_tracking_number', x, Array).map { |v| HttpClient::Preconditions.assert_class('carrier_tracking_number', v, String) }),
    :flow_tracking_number => (x = opts.delete(:flow_tracking_number); x.nil? ? nil : HttpClient::Preconditions.assert_class('flow_tracking_number', x, Array).map { |v| HttpClient::Preconditions.assert_class('flow_tracking_number', v, String) }),
    :order_number => (x = opts.delete(:order_number); x.nil? ? nil : HttpClient::Preconditions.assert_class('order_number', x, Array).map { |v| HttpClient::Preconditions.assert_class('order_number', v, String) }),
    :service => (x = opts.delete(:service); x.nil? ? nil : HttpClient::Preconditions.assert_class('service', x, Array).map { |v| HttpClient::Preconditions.assert_class('service', 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)}/shipping-notifications").with_query(query).get
  r.map { |x| ::Io::Flow::V0::Models::ShippingNotification.new(x) }
end

#get_by_key(organization, key) ⇒ Object



3066
3067
3068
3069
3070
3071
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 3066

def get_by_key(organization, key)
  HttpClient::Preconditions.assert_class('organization', organization, String)
  HttpClient::Preconditions.assert_class('key', key, String)
  r = @client.request("/#{CGI.escape(organization)}/shipping-notifications/#{CGI.escape(key)}").get
  ::Io::Flow::V0::Models::ShippingNotification.new(r)
end

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



3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 3088

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) }),
    :key => (x = opts.delete(:key); x.nil? ? nil : HttpClient::Preconditions.assert_class('key', x, Array).map { |v| HttpClient::Preconditions.assert_class('key', 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)}/shipping-notifications/versions").with_query(query).get
  r.map { |x| ::Io::Flow::V0::Models::ShippingNotificationVersion.new(x) }
end

#post(organization, shipping_notification_form) ⇒ Object



3059
3060
3061
3062
3063
3064
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 3059

def post(organization, shipping_notification_form)
  HttpClient::Preconditions.assert_class('organization', organization, String)
  (x = shipping_notification_form; x.is_a?(::Io::Flow::V0::Models::ShippingNotificationForm) ? x : ::Io::Flow::V0::Models::ShippingNotificationForm.new(x))
  r = @client.request("/#{CGI.escape(organization)}/shipping-notifications").with_json(shipping_notification_form.to_json).post
  ::Io::Flow::V0::Models::ShippingNotification.new(r)
end

#put_by_key(organization, key, shipping_notification_form) ⇒ Object



3073
3074
3075
3076
3077
3078
3079
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 3073

def put_by_key(organization, key, shipping_notification_form)
  HttpClient::Preconditions.assert_class('organization', organization, String)
  HttpClient::Preconditions.assert_class('key', key, String)
  (x = shipping_notification_form; x.is_a?(::Io::Flow::V0::Models::ShippingNotificationForm) ? x : ::Io::Flow::V0::Models::ShippingNotificationForm.new(x))
  r = @client.request("/#{CGI.escape(organization)}/shipping-notifications/#{CGI.escape(key)}").with_json(shipping_notification_form.to_json).put
  ::Io::Flow::V0::Models::ShippingNotification.new(r)
end