Class: Omise::Resource

Inherits:
Object
  • Object
show all
Defined in:
lib/omise/resource.rb

Constant Summary collapse

CA_BUNDLE_PATH =
File.expand_path("../../../data/ca_certificates.pem", __FILE__)

Instance Method Summary collapse

Constructor Details

#initialize(url, path, key) ⇒ Resource

Returns a new instance of Resource.



14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/omise/resource.rb', line 14

def initialize(url, path, key)
  @uri = URI.parse(url)
  @uri.path = [@uri.path, path].join
  @resource = RestClient::Resource.new(@uri.to_s, {
    user: key,
    verify_ssl: OpenSSL::SSL::VERIFY_PEER,
    ssl_ca_file: CA_BUNDLE_PATH,
    headers: {
      user_agent: "OmiseRuby/#{Omise::VERSION} OmiseAPI/#{Omise.api_version} Ruby/#{RUBY_VERSION}"
    }
  })
end

Instance Method Details

#deleteObject



39
40
41
# File 'lib/omise/resource.rb', line 39

def delete
  @resource.delete { |r| Omise::Util.load_response(r) }
end

#getObject



27
28
29
# File 'lib/omise/resource.rb', line 27

def get
  @resource.get { |r| Omise::Util.load_response(r) }
end

#patch(attributes) ⇒ Object



31
32
33
# File 'lib/omise/resource.rb', line 31

def patch(attributes)
  @resource.patch(attributes) { |r| Omise::Util.load_response(r) }
end

#post(attributes) ⇒ Object



35
36
37
# File 'lib/omise/resource.rb', line 35

def post(attributes)
  @resource.post(attributes) { |r| Omise::Util.load_response(r) }
end