Code Monkey home page Code Monkey logo

verifalia-ruby-sdk's People

Contributors

andreabeggiato avatar ecobisi avatar robertoschneiders avatar verifalia avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

verifalia-ruby-sdk's Issues

Undefined method `code' for nil:NilClass

validador_verifalia.rb is raising an undefined method code for nil:NilClass error when RestClient raise a RestClient::RequestTimeout

I'm already working on the fix.

RSpec is not running all tests

RSpec is not running the email_validations specs. The file has the wrong file name.

it is:
email_validations.spec.rb
should be:
email_validations_spec.rb

I will fix this and send a PR.

Need code updates to keep it DRY

I have following code update suggestions to keep code DRY. Working on following updates.

In EmailValidations#initialize

@resource = RestClient::Resource.new "#{config[:host]}/#{config[:api_version]}/email-validations", account_sid, account_token

Update above code to build @resource, with following

api_url = "#{config[:host]}/#{config[:api_version]}/email-validations"
opts = {
  user: account_sid, 
  password: account_token, 
  headers: { content_type: :json }
}
@resource = RestClient::Resource.new api_url, opts

I see following advantage,

  • We don't need to pass content_type: :json for each call like :get, :post, :delete

After this update we can call @resource.post, @resource.get without content_type.

Off course, We need to test code thoroughly, I have started working on it,
What you think @RobertoSchneiders ?, any thoughts?

Need to fix EmailValidations#query method as well

@verifalia
With reference to to my previous issue #4,

Need to fix EmailValidations#query method as well

Lets take a scenario, I start a job and get following response

unique_id = @client.email_validations.verify(emails)
@client.email_validations.query

{
   "uniqueID":"74169d7e-e8be-4ebb-aa5b-xxxxxxxx",
   "engineVersion":"1.2;2015-10-08",
   "submittedOn":"2015-10-20T12:27:40.023",
   "progress":{
       "noOfTotalEntries":3,
       "noOfCompletedEntries":2
   }
}

If I want to query again on same object @client.email_validations which has@unique_id and
@response have above value, If after some time I call @client.email_validations.query to see the latest status of same job with @unique_id

Following condition(unless) will never be false, as @response has non nil value after first call and will not query API again for latest status.

 def query
   ....
   unless @response
     #this part will not get executed 
   end 
   ....
 end

Note: This works if I have previous unique_id, What if I want to query on existing object without any arguments to @client.email_validations it should query using exiting @unique_id which exists with current object. May be we need to change the completed? and query method. So user can easily call query again on same object after some time using completed? method, keeping same support for @client.email_validations(unique_id: unique_id).query (with argument)

Will send PR, after fixing this.

Update API version

Currently the code uses version 1.4, but there's already version 2 of the api.

Need to fix EmailValidations#completed? method

While using this sdk, found bug in EmailValidations#completed? method as following
After creating validation job using

unique_id = @client.email_validations.verify(emails)
response = @client.email_validations.query

Got response as

{
   "uniqueID":"74169d7e-e8be-4ebb-aa5b-xxxxxxxx",
   "engineVersion":"1.2;2015-10-08",
   "submittedOn":"2015-10-20T12:27:40.023",
   "progress":{
       "noOfTotalEntries":3,
       "noOfCompletedEntries":2
   }
}

If we notice this job is in progress , I checked status using

@client.email_validations.completed?

And got true which is incorrect.

completed? method should be like

def completed?
   query["progress"]["noOfTotalEntries"] == query["progress"]["noOfCompletedEntries"]
end

@verifalia Waiting for your confirmation on this, So I can fix this and send PR.

Validation jobs incorrectly marked as completed

The EmailValidations class incorrectly marks a validation job as completed if the noOfCompletedEntries is equal to noOfTotalEntries:

https://github.com/verifalia/verifalia-ruby-sdk/blob/master/lib/rest/email_validations.rb#L88

This behavior is wrong, as the API returns the completion status for a validation job in a RESTful fashion: in particular, the HTTP 202 (Accepted) status code means the API consumer should reissue the request later (see http://verifalia.com/developers/email-validations#getting-status). Apart from compliance to the API specification, this behavior can cause issues if the API consumer expects to actually find its validation results whenever the SDK marks a validation job as completed.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.