Class: PaymentGateway::Mundipagg::Plan

Inherits:
Base
  • Object
show all
Defined in:
lib/payment_gateway/mundipagg/plan.rb

Constant Summary

Constants inherited from Base

Base::API_URL

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from PaymentGateway::Mundipagg::Base

Instance Method Details

#any?Boolean

Returns:

  • (Boolean)


12
13
14
# File 'lib/payment_gateway/mundipagg/plan.rb', line 12

def any?
  list&.any?
end

#create(plan_data) ⇒ Object

{

"name"           => "Básico",
"currency"       => "BRL",
"interval"       => "month",
"interval_count" => 1,
"billing_type"   => "prepaid",
"items" => [
  {
    "name"     => "Assinatura",
    "quantity" => 1,
    "pricing_scheme" => {
      # R$ 20,00
      "price" => 2000
    }
  }
],
"metadata" => {
  "id" => "plano-basico"
}

}



36
37
38
39
40
# File 'lib/payment_gateway/mundipagg/plan.rb', line 36

def create(plan_data)
  validate_plan_data(plan_data)
  creation_url = "#{API_URL}/plans"
  request(:post, creation_url, body: plan_data)
end

#destroy(plan_id) ⇒ Object



42
43
44
45
# File 'lib/payment_gateway/mundipagg/plan.rb', line 42

def destroy(plan_id)
  destruction_url = "#{API_URL}/plans/#{plan_id}"
  request(:delete, destruction_url)
end

#listObject



6
7
8
9
10
# File 'lib/payment_gateway/mundipagg/plan.rb', line 6

def list
  list_url = "#{API_URL}/plans"
  response = request(:get, list_url)
  response
end