Class: Stripe::UsageRecord

Inherits:
APIResource show all
Defined in:
lib/stripe/resources/usage_record.rb

Constant Summary collapse

OBJECT_NAME =
"usage_record".freeze

Instance Attribute Summary

Attributes inherited from APIResource

#save_with_parent

Class Method Summary collapse

Methods inherited from APIResource

class_name, custom_method, #refresh, resource_url, #resource_url, retrieve, save_nested_resource

Methods included from APIOperations::Request

included

Methods inherited from StripeObject

#==, #[], #[]=, additive_object_param, additive_object_param?, #as_json, construct_from, #deleted?, #dirty!, #each, #eql?, #hash, #initialize, #inspect, #keys, #marshal_dump, #marshal_load, protected_fields, #refresh_from, serialize_params, #serialize_params, #to_hash, #to_json, #to_s, #update_attributes, #values

Constructor Details

This class inherits a constructor from Stripe::StripeObject

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Stripe::StripeObject

Class Method Details

.create(params = {}, opts = {}) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/stripe/resources/usage_record.rb', line 7

def self.create(params = {}, opts = {})
  unless params.key?(:subscription_item)
    raise ArgumentError, "Params must have a subscription_item key"
  end
  req_params = params.clone.delete_if do |key, _value|
    key == :subscription_item
  end
  resp, opts = request(
    :post,
    "/v1/subscription_items/#{params[:subscription_item]}/usage_records",
    req_params,
    opts
  )
  Util.convert_to_stripe_object(resp.data, opts)
end