Skip to content

Instantly share code, notes, and snippets.

@DanielVartanov
Last active November 13, 2019 15:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DanielVartanov/af4dffe87f4d7921140eaa4b5c07b807 to your computer and use it in GitHub Desktop.
Save DanielVartanov/af4dffe87f4d7921140eaa4b5c07b807 to your computer and use it in GitHub Desktop.

Veeqo 2nd line engineer tech assignment

0. Learn the basics of Ruby programming language

Probably the easiest way is to use Ruby in Twenty Minutes

1. Install Ruby on your computer

Use either official instruction or any other instruction our there on the internet. Please make sure you install Ruby version 2.6

2. Install http gem

Usually it's done by running gem install http in your terminal

3. Run your first ruby file

Create a file assignment.rb and type inside:

require 'http'

puts 'John Smith'

If you did everything right then executing this file (usually by running ruby assignment.rb in a terminal) should result in printing words "Johm Smith" in your terminal

Now make it print your name instead of "John Smith".

4. Make a simple request to Veeqo

Amend the code in assignment.rb code as follows:

require 'http'

response = HTTP.get('https://app.veeqo.com/')
puts response.status

puts 'John Smith'

If you did everything right then after executing the file it should print

200 OK
John Smith

Here and below we assume that "John Smith" is substituted with your name.

5. Request a sales order information from Veeqo

Veeqo is about e-commerce which's very heart is a sales order. So now instead of sending a request to 'https://app.veeqo.com/' please edit the code so that it sends a request to 'https://app.veeqo.com/orders/34876370'.

Expected output:

302 Found
John Smith

6. Add a header to your request

Please see documentation of http gem to learn how to add a header to your request. You are to add a header of :accept => "application/json" to the request.

Expected output:

401 Unauthorized
John Smith

7. Add authorisation cookies to your request

Veeqo did not recognise you in the previous step and therefore did not expose a sensitive information to you. Please fix that by adding a cookie to your request.

The cookie has to be the following: :_veeqo_session_v3 => 'BAh7CEkiD3Nlc3Npb25faWQGOgZFVEkiJWE3NzI1MjliOGE4NWVlN2JkYTdmNmY3Y2U0ZmE0ZmEzBjsAVEkiEF9jc3JmX3Rva2VuBjsARkkiMVdpNURKdEJvV0g5aXMydHhZbnJsb0NYVkdpczBRNXp5YVlmSVk2N2xGenc9BjsARkkiFGN1cnJlbnRfdXNlcl9pZAY7AEZpAhBv--5fc15099e7cc294675479044baf0a6f7ef27b1d7'

Please search documentation of http gem for the hints on how to add cookies to a request (but don't forget to keep the header in place).

If you added the cookie correctly the output should like like:

200 OK
John Smith

8. Extract data from Veeqo response

200 OK in the previous step indicates that Veeqo returned some real life data in response to your request. It's time to inspect it. Right after the line puts response.status in your assignment.rb please add the following line:

puts response.parse['total_price']

It should make the script print the total price of the order:

200 OK
3600.0
John Smith

9. Extract the customer billing address data from the order

An order has a customer, a customer has a billing address, a billing address has its own attributes. If you try to print response.parse['customer']['billing_address'] you will see all the attributes of the billing address, you'll also see that a billing address is actually a Ruby hash. The last step is to make your script print full name and city of the billing address.

Expected output:

200 OK
3600.0
ade mitchell
Swansea
John Smith

Please note that the first name and the last name should be printed on the same line.

When you are done please send us your assignment.rb file, it should print what is expected in the step #9 when run.

@Kanybek1295
Copy link

Данил, здравствуйте! остановился на 7 пункте, логику понял, с синтаксисом ruby немного трудновато.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment