Class: Omise::Resource
- Inherits:
-
Object
- Object
- Omise::Resource
- Defined in:
- lib/omise/resource.rb
Constant Summary collapse
- CA_BUNDLE_PATH =
File.("../../../data/ca_certificates.pem", __FILE__)
- DEFAULT_HEADERS =
{ user_agent: "OmiseRuby/#{Omise::VERSION} Ruby/#{RUBY_VERSION}", }
Instance Attribute Summary collapse
-
#headers ⇒ Object
readonly
Returns the value of attribute headers.
-
#key ⇒ Object
readonly
Returns the value of attribute key.
-
#uri ⇒ Object
readonly
Returns the value of attribute uri.
Instance Method Summary collapse
- #delete ⇒ Object
- #get(attributes = {}) ⇒ Object
-
#initialize(url, path, key) ⇒ Resource
constructor
A new instance of Resource.
- #patch(attributes = {}) ⇒ Object
- #post(attributes = {}) ⇒ Object
Constructor Details
#initialize(url, path, key) ⇒ Resource
Returns a new instance of Resource.
15 16 17 18 19 20 21 |
# File 'lib/omise/resource.rb', line 15 def initialize(url, path, key) @uri = prepare_uri(url, path) @headers = prepare_headers @key = key set_resource end |
Instance Attribute Details
#headers ⇒ Object (readonly)
Returns the value of attribute headers.
23 24 25 |
# File 'lib/omise/resource.rb', line 23 def headers @headers end |
#key ⇒ Object (readonly)
Returns the value of attribute key.
23 24 25 |
# File 'lib/omise/resource.rb', line 23 def key @key end |
#uri ⇒ Object (readonly)
Returns the value of attribute uri.
23 24 25 |
# File 'lib/omise/resource.rb', line 23 def uri @uri end |
Instance Method Details
#delete ⇒ Object
51 52 53 54 55 56 |
# File 'lib/omise/resource.rb', line 51 def delete @resource.delete do |response, request| log(request, response) Omise::Util.load_response(response) end end |
#get(attributes = {}) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/omise/resource.rb', line 25 def get(attributes = {}) if attributes.any? @uri.query = Omise::Util.generate_query(attributes) set_resource end @resource.get do |response, request| log(request, response) Omise::Util.load_response(response) end end |
#patch(attributes = {}) ⇒ Object
37 38 39 40 41 42 |
# File 'lib/omise/resource.rb', line 37 def patch(attributes = {}) @resource.patch(attributes) do |response, request| log(request, response) Omise::Util.load_response(response) end end |
#post(attributes = {}) ⇒ Object
44 45 46 47 48 49 |
# File 'lib/omise/resource.rb', line 44 def post(attributes = {}) @resource.post(attributes) do |response, request| log(request, response) Omise::Util.load_response(response) end end |