Module: STP::Account
- Defined in:
- lib/stp/account.rb
Class Method Summary collapse
Class Method Details
.create(account) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 |
# File 'lib/stp/account.rb', line 3 def self.create(account) account.signature = Crypto::Commons.rsa_seal(STP.private_key, STP.private_key_password, account.original_chain) connection = Faraday.new(url: "#{STP.api_uri}/cuentaModule/fisica") response = connection.put do |req| req.url '' req.headers['Content-Type'] = 'application/json' req.body = account.to_json end hash = JSON.parse(response.body) raise STP::STPError.new(hash['message']) unless hash['id'] == 0 end |
.delete(account) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/stp/account.rb', line 15 def self.delete(account) account.signature = Crypto::Commons.rsa_seal(STP.private_key, STP.private_key_password, account.original_chain) connection = Faraday.new(url: "#{STP.api_uri}/cuentaModule/fisica") response = connection.delete do |req| req.url '' req.headers['Content-Type'] = 'application/json' req.body = account.to_json end hash = JSON.parse(response.body) raise STP::STPError.new(hash['message']) unless hash['id'] == 0 end |