Sha256: 04d4c9c95f7dfc875c3dd712a7498e2ba1f21dffe9e7ba4d78dc0a06651f5d96

Contents?: true

Size: 549 Bytes

Versions: 5

Compression:

Stored size: 549 Bytes

Contents

module PagSeguro
  class Plans < Base
    def create(params)
      params[:amount_per_payment] = to_money params[:amount_per_payment]
      params = parameterize params

      parse_body api.post("/pre-approvals/request", preApproval: params)
    end

    def update(code, params)
      params[:amount_per_payment] = to_money params[:amount_per_payment]
      params = parameterize params

      api.put "/pre-approvals/request/#{code}/payment", params
    end

    private

    def to_money(value)
      format "%.2f", value.to_f
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
pagseguro_next-0.4.0 lib/pagseguro/plans.rb
pagseguro_next-0.3.0 lib/pagseguro/plans.rb
pagseguro_next-0.2.0 lib/pagseguro/plans.rb
pagseguro_next-0.1.1 lib/pagseguro/plans.rb
pagseguro_next-0.1.0 lib/pagseguro/plans.rb