Class: Ifns::Client
- Inherits:
-
Object
- Object
- Ifns::Client
- Defined in:
- lib/ifns/client.rb
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
Instance Method Summary collapse
- #create_ticket ⇒ Object
- #create_validation ⇒ Object
- #find_ticket ⇒ Object
- #find_validation ⇒ Object
-
#initialize(options) ⇒ Client
constructor
A new instance of Client.
- #params ⇒ Object
Constructor Details
#initialize(options) ⇒ Client
Returns a new instance of Client.
5 6 7 8 |
# File 'lib/ifns/client.rb', line 5 def initialize() @data = OpenStruct.new() validate_keys end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
3 4 5 |
# File 'lib/ifns/client.rb', line 3 def data @data end |
Instance Method Details
#create_ticket ⇒ Object
32 33 34 35 36 37 38 39 40 41 |
# File 'lib/ifns/client.rb', line 32 def create_ticket caching(key: "ifns:ticket_id:#{data.id}", expire: 60.seconds) do response = connection.post('/api/v1/tickets') do |req| req.headers['Content-Type'] = 'application/json' req.headers['X-Auth-Token'] = Ifns.configuration.token req.body = params.to_json end Responses::Ticket.new(response) end end |
#create_validation ⇒ Object
14 15 16 17 18 19 20 21 22 23 |
# File 'lib/ifns/client.rb', line 14 def create_validation caching(key: "ifns:validation_id:#{data.id}", expire: 60.seconds) do response = connection.post('/api/v1/validations') do |req| req.headers['Content-Type'] = 'application/json' req.headers['X-Auth-Token'] = Ifns.configuration.token req.body = params.to_json end Responses::Validation.new(response) end end |
#find_ticket ⇒ Object
43 44 45 46 47 48 |
# File 'lib/ifns/client.rb', line 43 def find_ticket response = connection.get("/api/v1/tickets/#{create_ticket.id}") do |req| req.headers['X-Auth-Token'] = Ifns.configuration.token end Responses::Ticket.new(response) end |
#find_validation ⇒ Object
25 26 27 28 29 30 |
# File 'lib/ifns/client.rb', line 25 def find_validation response = connection.get("/api/v1/validations/#{create_validation.id}") do |req| req.headers['X-Auth-Token'] = Ifns.configuration.token end Responses::Validation.new(response) end |
#params ⇒ Object
10 11 12 |
# File 'lib/ifns/client.rb', line 10 def params { fn: data.fn, fd: data.fd, fpd: data.fpd, sum: data.sum, date: data.date, type_operation: data.type_operation } end |