Class: Coloredcoins::Connection
- Inherits:
-
Object
- Object
- Coloredcoins::Connection
- Defined in:
- lib/coloredcoins/connection.rb
Instance Attribute Summary collapse
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Instance Method Summary collapse
- #get(path, payload = {}) ⇒ Object
-
#initialize(url = nil) ⇒ Connection
constructor
A new instance of Connection.
- #post(path, payload = {}) ⇒ Object
- #query(method, path, payload = {}) ⇒ Object
Constructor Details
#initialize(url = nil) ⇒ Connection
Returns a new instance of Connection.
7 8 9 |
# File 'lib/coloredcoins/connection.rb', line 7 def initialize(url = nil) @url = url end |
Instance Attribute Details
#url ⇒ Object (readonly)
Returns the value of attribute url.
5 6 7 |
# File 'lib/coloredcoins/connection.rb', line 5 def url @url end |
Instance Method Details
#get(path, payload = {}) ⇒ Object
11 12 13 |
# File 'lib/coloredcoins/connection.rb', line 11 def get(path, payload = {}) query :get, path, payload end |
#post(path, payload = {}) ⇒ Object
15 16 17 |
# File 'lib/coloredcoins/connection.rb', line 15 def post(path, payload = {}) query :post, path, payload end |
#query(method, path, payload = {}) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/coloredcoins/connection.rb', line 19 def query(method, path, payload = {}) uri = endpoint_uri(path) response = RestClient::Request.execute( method: method, url: uri, payload: payload, ssl_version: 'SSLv23' ) JSON.parse(response, symbolize_names: true) rescue RestClient::ExceptionWithResponse => e raise Coloredcoins::ConnectionError, e.response end |