Class: Flespi
- Inherits:
-
Object
- Object
- Flespi
- Defined in:
- lib/flespi.rb
Constant Summary collapse
- VERSION =
"1.0.2.1"
Instance Attribute Summary collapse
-
#debug ⇒ Object
Returns the value of attribute debug.
-
#flespi_token ⇒ Object
Returns the value of attribute flespi_token.
Instance Method Summary collapse
- #create(url, parameters) ⇒ Object
- #delete(url) ⇒ Object
- #get(url) ⇒ Object
-
#initialize(flespi_token, debug: false) ⇒ Flespi
constructor
A new instance of Flespi.
- #update(url, parameters) ⇒ Object
Constructor Details
#initialize(flespi_token, debug: false) ⇒ Flespi
Returns a new instance of Flespi.
12 13 14 15 |
# File 'lib/flespi.rb', line 12 def initialize(flespi_token, debug: false) self.flespi_token = flespi_token self.debug = debug end |
Instance Attribute Details
#debug ⇒ Object
Returns the value of attribute debug.
8 9 10 |
# File 'lib/flespi.rb', line 8 def debug @debug end |
#flespi_token ⇒ Object
Returns the value of attribute flespi_token.
8 9 10 |
# File 'lib/flespi.rb', line 8 def flespi_token @flespi_token end |
Instance Method Details
#create(url, parameters) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/flespi.rb', line 31 def create(url, parameters) uri = URI.parse("https://flespi.io#{url}") if debug puts "================ FLESPI REQUEST ================" puts "Request: POST https://flespi.io#{url}" puts "================================================" end request = Net::HTTP::Post.new(uri) validate_response(make_request(request, uri, parameters)) end |
#delete(url) ⇒ Object
59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/flespi.rb', line 59 def delete(url) uri = URI.parse("https://flespi.io#{url}") if debug puts "================ FLESPI REQUEST ================" puts "Request: DELETE https://flespi.io#{url}" puts "================================================" end request = Net::HTTP::Delete.new(uri) validate_response(make_request(request, uri)) end |
#get(url) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/flespi.rb', line 17 def get(url) uri = URI.parse("https://flespi.io#{url}") if debug puts "================ FLESPI REQUEST ================" puts "Request: GET https://flespi.io#{url}" puts "================================================" end request = Net::HTTP::Get.new(uri) validate_response(make_request(request, uri)) end |
#update(url, parameters) ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/flespi.rb', line 45 def update(url, parameters) uri = URI.parse("https://flespi.io#{url}") if debug puts "================ FLESPI REQUEST ================" puts "Request: PUT https://flespi.io#{url}" puts "================================================" end request = Net::HTTP::Put.new(uri) validate_response(make_request(request, uri, parameters)) end |