TCP Issues Rails

Hello, I’m having this issue while trying to implement the Stuart API on Rails. Does anyone has a solution? Thanks !

1 Like

Hello @willguill,

Thank you for your post,

It seems that you are using an older version of our client library.
A change has been made regarding the sandbox URL which is now: https://api.sandbox.stuart.com.

Everything will work as expected if you upgrade to the latest version of our library.

Feel free to contact us again if you have further questions.

Cheers

1 Like

Hello Adrien,

I’m using the code that is mentioned on this page since I’m coding my app thanks to ruby on Rails : GitHub - StuartApp/stuart-client-ruby: Stuart Ruby client

My code looks like this

def stuart_job
    environment = Stuart::Infrastructure::Environment::SANDBOX
    api_client_id = 'aa6e5a50b44cc6d92c38cde88f35fea75aaf3a631299ef9ab5f5f0ff8e3c9461' # can be found here: https://admin.sandbox.stuart.com/client/api
    api_client_secret = 'e2af3d89b712a79357dfd7b99d9eb2de868e423e579c07a69b2cfccbdba23e60' # can be found here: https://admin.sandbox.stuart.com/client/api
    auth = Stuart::Infrastructure::Authenticator.new(environment, api_client_id, api_client_secret)
    http_client = Stuart::Infrastructure::HttpClient.new(auth)
    job = {
  job: {
    transport_type: "bike",
    pickups: [
      {
        address: "46 Boulevard Barbès, 75018 Paris",
        comment: "Wait outside for an employee to come.",
        contact: {
          firstname: "Martin",
          lastname: "Pont",
          phone: "+33698348756",
          company: "KFC Paris Barbès"
        }
      }
    ],
    dropoffs: [
      {
        address: "156 rue de Charonne, 75011 Paris",
        package_description: "Red packet.",
        client_reference: "12345678ABCDE", # must be unique
        comment: "code: 3492B. 3e étage droite. Sonner à Durand.",
        contact: {
          firstname: "Alex",
          lastname: "Durand",
          phone: "+33634981209",
          company: "Durand associates."
        }
      }
    ]
  }
}

http_client.perform_post '/v2/jobs', JSON.generate(job)
  end

It doesn’t mention any URL for the moment. Can you help me? Regards.

Hello @willguill,

Thank you for your response

To prevent this issue you can replace the environment variable in your code with this snippet:

class Environment
    SANDBOX = { base_url: "https://api.sandbox.stuart.com" }.freeze

    PRODUCTION = { base_url: "https://api.stuart.com" }.freeze
end

environment = Environment::SANDBOX

It will prevent this error to occur for both Sandbox and Production.

Note that we are currently working on deploying a new version of the library that will solve this issue.

Cheers