项目作者: StuartApp

项目描述 :
Stuart Ruby client
高级语言: Ruby
项目地址: git://github.com/StuartApp/stuart-client-ruby.git
创建时间: 2018-02-09T16:45:54Z
项目社区:https://github.com/StuartApp/stuart-client-ruby

开源协议:MIT License

下载


Codeship Status for StuartApp/stuart-client-ruby

Stuart Ruby Client

For a complete documentation of all endpoints offered by the Stuart API, you can visit Stuart API documentation.

Install

  1. $ gem install stuart-client-ruby

Usage

Initialize HTTP client

  1. require 'stuart-client-ruby'
  2. environment = Stuart::Infrastructure::Environment::SANDBOX
  3. api_client_id = 'c6058849d0a056fc743203acb8e6a850dad103485c3edc51b16a9260cc7a7689' # can be found here: https://admin.sandbox.stuart.com/client/api
  4. api_client_secret = 'aa6a415fce31967501662c1960fcbfbf4745acff99acb19dbc1aae6f76c9c618' # can be found here: https://admin.sandbox.stuart.com/client/api
  5. auth = Stuart::Infrastructure::Authenticator.new(environment, api_client_id, api_client_secret)
  6. http_client = Stuart::Infrastructure::HttpClient.new(auth)

Custom requests

Example: create a job

  1. job = {
  2. job: {
  3. transport_type: "bike",
  4. pickups: [
  5. {
  6. address: "46 Boulevard Barbès, 75018 Paris",
  7. comment: "Wait outside for an employee to come.",
  8. contact: {
  9. firstname: "Martin",
  10. lastname: "Pont",
  11. phone: "+33698348756",
  12. company: "KFC Paris Barbès"
  13. }
  14. }
  15. ],
  16. dropoffs: [
  17. {
  18. address: "156 rue de Charonne, 75011 Paris",
  19. package_description: "Red packet.",
  20. client_reference: "12345678ABCDE", # must be unique
  21. comment: "code: 3492B. 3e étage droite. Sonner à Durand.",
  22. contact: {
  23. firstname: "Alex",
  24. lastname: "Durand",
  25. phone: "+33634981209",
  26. company: "Durand associates."
  27. }
  28. }
  29. ]
  30. }
  31. }
  32. http_client.perform_post '/v2/jobs', JSON.generate(job)

Example: get a list of jobs

  1. http_client.perform_get('/v2/jobs')

Release process

  1. Review the Gem version in lib/stuart-client-ruby/version.rb
  2. Create and publish a Git tag with the version defined in lib/stuart-client-ruby/version.rb
    Example:

    1. git tag v1.2.0-rc.1
    2. git push origin --tags
  3. The workflow workflows/publish.yml should start and publish the new version to Rubygems https://rubygems.org/gems/stuart-client-ruby