Module: Vindi

Defined in:
lib/vindi.rb,
lib/vindi/version.rb,
lib/vindi/rate_limit.rb,
lib/vindi/models/bill.rb,
lib/vindi/models/plan.rb,
lib/vindi/models/issue.rb,
lib/vindi/models/model.rb,
lib/vindi/models/charge.rb,
lib/vindi/models/period.rb,
lib/vindi/models/address.rb,
lib/vindi/models/product.rb,
lib/vindi/models/customer.rb,
lib/vindi/models/discount.rb,
lib/vindi/models/bill_item.rb,
lib/vindi/models/plan_item.rb,
lib/vindi/models/transaction.rb,
lib/vindi/models/notification.rb,
lib/vindi/models/product_item.rb,
lib/vindi/models/subscription.rb,
lib/vindi/models/payment_method.rb,
lib/vindi/models/pricing_schema.rb,
lib/vindi/models/payment_profile.rb,
lib/vindi/middleware/response_parser.rb,
lib/vindi/middleware/rate_limit_validation.rb

Overview

Saves the rate limts from Vindi responses.

Defined Under Namespace

Modules: Middleware Classes: Address, Bill, BillItem, Charge, Customer, Discount, Error, Issue, Model, Notitication, PaymentMethod, PaymentProfile, Period, Plan, PlanItem, PricingSchema, Product, ProductItem, RateLimit, RateLimitError, Subscription, Transactiton

Constant Summary collapse

RESOURCE_MODELS =
Dir[File.expand_path("vindi/models/**/*.rb", File.dirname(__FILE__))].freeze
VINDI_API_URL =
"https://app.vindi.com.br/api/v1"
VINDI_SANDBOX_API_URL =
"https://sandbox-app.vindi.com.br/api/v1"
VERSION =
"0.0.2"
@@sandbox =
false
@@api_key =
false
@@webhook_name =
nil
@@webhook_password =
nil

Class Method Summary collapse

Class Method Details

.api_urlObject



44
45
46
47
48
# File 'lib/vindi.rb', line 44

def self.api_url
  return VINDI_SANDBOX_API_URL if @@sandbox

  VINDI_API_URL
end

.config {|_self| ... } ⇒ Object

Examples:

Vindi.setup do |c|
  c.sandbox = true
  c.api_key = 'MY API KEY'
end

Yields:

  • (_self)

Yield Parameters:

  • _self (Vindi)

    the object that the method was called on



56
57
58
59
60
# File 'lib/vindi.rb', line 56

def self.config
  yield self

  her_setup
end

.her_setupObject



63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# File 'lib/vindi.rb', line 63

def self.her_setup
  Her::API.setup url: Vindi.api_url do |conn|
    conn.basic_auth Vindi.api_key, ""

    # Request
    conn.use ::Vindi::Middleware::RateLimitValidation
    conn.request :json

    # Response
    conn.response :json, content_type: /\bjson$/
    conn.use ::Vindi::Middleware::ResponseParser

    # Adapter
    conn.adapter Faraday.default_adapter
  end
end