Sha256: 59eebdbf9ac291bee3f066f153facce10983e07ea77899ddbec3649c19495909
Contents?: true
Size: 1.85 KB
Versions: 2
Compression:
Stored size: 1.85 KB
Contents
module Moip::Assinaturas class Plan class << self def create(plan) response = Moip::Assinaturas::Client.create_plan(plan) hash = JSON.load(response.body).with_indifferent_access case response.code when 201 return { success: true, plan: hash } when 400 return { success: false, message: hash['message'], errors: hash['errors'] } else raise(WebServerResponseError, "Ocorreu um erro no retorno do webservice") end end def list response = Moip::Assinaturas::Client.list_plans hash = JSON.load(response.body).with_indifferent_access case response.code when 200 return { success: true, plans: hash[:plans] } else raise(WebServerResponseError, "Ocorreu um erro no retorno do webservice") end end def details(code) response = Moip::Assinaturas::Client.details_plan(code) hash = JSON.load(response.body).with_indifferent_access case response.code when 200 return { success: true, plan: hash } else raise(WebServerResponseError, "Ocorreu um erro no retorno do webservice") end end def update(plan) response = Moip::Assinaturas::Client.update_plan(plan) # in the current implementation the Moip signatures API only # returns response code 200 with an empty body even if the update fails case response.code when 200 return { success: true } else raise(WebServerResponseError, "Ocorreu um erro no retorno do webservice") end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
moip-assinaturas-0.1.3 | lib/moip-assinaturas/plan.rb |
moip-assinaturas-0.1.2 | lib/moip-assinaturas/plan.rb |