Sha256: 5d48ccbe27878b52e70f5d32f5dcfd4e992e92c3090f7a64190e19601c18ef88

Contents?: true

Size: 916 Bytes

Versions: 1

Compression:

Stored size: 916 Bytes

Contents

require 'net/http'
require 'json'
# module
module Itexmo
  # service
  class Service
    attr_accessor :api_code

    API_ENDPOINT = 'https://www.itexmo.com/php_api'.freeze

    def initialize
      @api_code = Itexmo.configuration.api_code
    end

    def status
      uri = URI(API_ENDPOINT + '/serverstatus.php')
      uri.query = URI.encode_www_form(parameters)
      request = Net::HTTP.get_response(uri)
      ResponseHelper.parse(request.body)
    end

    def self.status
      instance = new
      instance.status
    end

    def apicode_info
      uri = URI(API_ENDPOINT + '/apicode_info.php')
      uri.query = URI.encode_www_form(parameters)
      request = Net::HTTP.get_response(uri)
      ResponseHelper.parse(request.body)
    end

    def self.apicode_info
      instance = new
      instance.apicode_info
    end

    private

    def parameters
      { 'apicode' => api_code }
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
itexmo-0.0.1 lib/itexmo/service.rb