Skip to content

Instantly share code, notes, and snippets.

@joelind
Last active August 29, 2015 14:20
Show Gist options
  • Save joelind/a9e6e94b421bfc2d1b41 to your computer and use it in GitHub Desktop.
Save joelind/a9e6e94b421bfc2d1b41 to your computer and use it in GitHub Desktop.
6 transactions to http://qa-api.ea.autodesk.com
POST /admin/v1/accounts HTTP/1.1
User-Agent: Faraday v0.9.1
Content-Type: application/x-www-form-urlencoded
Accept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3
Accept: */*
Connection: close
Content-Length: 478
Host: qa-api.ea.autodesk.com
category=paid&corporate_account_name=Account+3daeed5b-44e1-4110-83e5-a610176413f6&corporate_account_number=Account+3daeed5b-44e1-4110-83e5-a610176413f6&display_name=Account+3daeed5b-44e1-4110-83e5-a610176413f6&email=joe.lind%2Bc2e2c02f-11e2-4291-aa82-27b7741e70ae%40autodesk.com&end_date=2021-01-01&name=Account+3daeed5b-44e1-4110-83e5-a610176413f6&price_model=enterprise_unlimited&project_exports_enabled=true&service_types=field&start_date=2001-01-01&user_exports_enabled=true
HTTP/1.1 201 Created
Cache-Control: max-age=0, private, must-revalidate
Content-Type: application/json; charset=utf-8
Date: Wed, 06 May 2015 18:36:46 GMT
ETag: "ccca7a85ebca601a7aff1bb3f918d162"
Server: Apache
Status: 201 Created
X-Content-Type-Options: nosniff
X-Frame-Options: SAMEORIGIN
X-Powered-By: Phusion Passenger 4.0.53
X-Request-Id: 0f931c1b-5dc4-4de8-adc1-d8b00763ed9e
X-Runtime: 0.224098
X-XSS-Protection: 1; mode=block
Content-Length: 878
Connection: Close
{"id":"6120dc1f-851a-4302-888e-e16f0ef38e24","name":"Account 3daeed5b-44e1-4110-83e5-a610176413f6","display_name":"Account 3daeed5b-44e1-4110-83e5-a610176413f6","category":"paid","price_model":"enterprise_unlimited","start_date":"2001-01-01T00:00:00.000Z","end_date":"2021-01-01T00:00:00.000Z","status":"active","status_reason":null,"max_projects":null,"project_exports_enabled":null,"max_users":null,"user_exports_enabled":null,"corporate_account_name":"Account 3daeed5b-44e1-4110-83e5-a610176413f6","corporate_account_number":"Account 3daeed5b-44e1-4110-83e5-a610176413f6","deprecated_image_url":null,"website_url":null,"created_at":"2015-05-06T18:36:46.642Z","updated_at":"2015-05-06T18:36:46.642Z","image_file_name":null,"image_content_type":null,"image_file_size":null,"image_updated_at":null,"processing_image_key":null,"company_id":"d4fe5667-378f-4a7c-bcbf-f1cf2ecec942"}
POST /admin/v1/accounts/6120dc1f-851a-4302-888e-e16f0ef38e24/projects HTTP/1.1
User-Agent: Faraday v0.9.1
Content-Type: application/x-www-form-urlencoded
Accept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3
Accept: */*
Connection: close
Content-Length: 102
Host: qa-api.ea.autodesk.com
end_date=2021-01-01T00%3A00%3A00%2B00%3A00&name=Project+A&start_date=2001-01-01T00%3A00%3A00%2B00%3A00
HTTP/1.1 201 Created
Cache-Control: max-age=0, private, must-revalidate
Content-Type: application/json; charset=utf-8
Date: Wed, 06 May 2015 18:36:46 GMT
ETag: "f9bbe69fabf474360a6b2524a07376eb"
Server: Apache
Status: 201 Created
X-Content-Type-Options: nosniff
X-Frame-Options: SAMEORIGIN
X-Powered-By: Phusion Passenger 4.0.53
X-Request-Id: 7bbe7eac-5095-47c2-aa78-3cc67c2c331c
X-Runtime: 0.128583
X-XSS-Protection: 1; mode=block
Content-Length: 798
Connection: Close
{"id":"2a467e92-651b-4a19-9830-661359a190f7","account_id":"6120dc1f-851a-4302-888e-e16f0ef38e24","name":"Project A","start_date":"2001-01-01T00:00:00.000Z","end_date":"2021-01-01T00:00:00.000Z","value":null,"currency":null,"status":"inactive","total_member_size":0,"total_company_size":1,"deprecated_image_url":null,"job_number":null,"address_line_1":null,"address_line_2":null,"city":null,"state_or_province":null,"postal_code":null,"country":null,"business_unit_id":null,"work_location":null,"work_breakdown":null,"created_at":"2015-05-06T18:36:46.911Z","updated_at":"2015-05-06T18:36:46.977Z","project_type":null,"image_file_name":null,"image_content_type":null,"image_file_size":null,"image_updated_at":null,"processing_image_key":null,"timezone":null,"status_reason":"pending","language":null}
POST /admin/v1/accounts/6120dc1f-851a-4302-888e-e16f0ef38e24/projects HTTP/1.1
User-Agent: Faraday v0.9.1
Content-Type: application/x-www-form-urlencoded
Accept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3
Accept: */*
Connection: close
Content-Length: 102
Host: qa-api.ea.autodesk.com
end_date=2021-01-01T00%3A00%3A00%2B00%3A00&name=Project+B&start_date=2001-01-01T00%3A00%3A00%2B00%3A00
HTTP/1.1 201 Created
Cache-Control: max-age=0, private, must-revalidate
Content-Type: application/json; charset=utf-8
Date: Wed, 06 May 2015 18:36:47 GMT
ETag: "2d33d433a1a6736dcc4541f78cf5dbd4"
Server: Apache
Status: 201 Created
X-Content-Type-Options: nosniff
X-Frame-Options: SAMEORIGIN
X-Powered-By: Phusion Passenger 4.0.53
X-Request-Id: d42411df-200e-4b68-9db3-f4874f1257ee
X-Runtime: 0.122273
X-XSS-Protection: 1; mode=block
Content-Length: 798
Connection: Close
{"id":"eac2fef4-4bea-44b9-9c20-2e905768478a","account_id":"6120dc1f-851a-4302-888e-e16f0ef38e24","name":"Project B","start_date":"2001-01-01T00:00:00.000Z","end_date":"2021-01-01T00:00:00.000Z","value":null,"currency":null,"status":"inactive","total_member_size":0,"total_company_size":1,"deprecated_image_url":null,"job_number":null,"address_line_1":null,"address_line_2":null,"city":null,"state_or_province":null,"postal_code":null,"country":null,"business_unit_id":null,"work_location":null,"work_breakdown":null,"created_at":"2015-05-06T18:36:47.096Z","updated_at":"2015-05-06T18:36:47.155Z","project_type":null,"image_file_name":null,"image_content_type":null,"image_file_size":null,"image_updated_at":null,"processing_image_key":null,"timezone":null,"status_reason":"pending","language":null}
POST /admin/v1/accounts/6120dc1f-851a-4302-888e-e16f0ef38e24/projects/2a467e92-651b-4a19-9830-661359a190f7/users HTTP/1.1
User-Agent: Faraday v0.9.1
Content-Type: application/x-www-form-urlencoded
Accept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3
Accept: */*
Connection: close
Content-Length: 135
Host: qa-api.ea.autodesk.com
company_id=d4fe5667-378f-4a7c-bcbf-f1cf2ecec942&email=joe.lind%2Bca6feaca-f04c-45d9-8e4d-a55a91f06b07%40autodesk.com&service_type=field
HTTP/1.1 201 Created
Cache-Control: max-age=0, private, must-revalidate
Content-Type: application/json; charset=utf-8
Date: Wed, 06 May 2015 18:36:47 GMT
ETag: "6eec436c8e939884ec4778e4e2cfa3b8"
Server: Apache
Status: 201 Created
X-Content-Type-Options: nosniff
X-Frame-Options: SAMEORIGIN
X-Powered-By: Phusion Passenger 4.0.53
X-Request-Id: db7af375-a2db-40e2-9499-b7afb626849f
X-Runtime: 0.189124
X-XSS-Protection: 1; mode=block
Content-Length: 380
Connection: Close
{"id":"e682b660-bd87-46e1-93ec-0f7c2d6222b0","account_user_id":"9a10c5c4-4c3d-4f23-9bb9-d95f969a8ac5","project_company_id":"d7230926-f42a-4dd5-8270-ef7362337cc6","user_id":"b371c2c5-4928-4210-841b-d451d5bfa315","service_project_id":"a0d0b6bf-0055-44c8-b2ae-a8b11166a820","invite_id":null,"role":null,"created_at":"2015-05-06T18:36:47.345Z","updated_at":"2015-05-06T18:36:47.345Z"}
POST /admin/v1/accounts/6120dc1f-851a-4302-888e-e16f0ef38e24/projects/eac2fef4-4bea-44b9-9c20-2e905768478a/users HTTP/1.1
User-Agent: Faraday v0.9.1
Content-Type: application/x-www-form-urlencoded
Accept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3
Accept: */*
Connection: close
Content-Length: 135
Host: qa-api.ea.autodesk.com
company_id=d4fe5667-378f-4a7c-bcbf-f1cf2ecec942&email=joe.lind%2Bca6feaca-f04c-45d9-8e4d-a55a91f06b07%40autodesk.com&service_type=field
HTTP/1.1 201 Created
Cache-Control: max-age=0, private, must-revalidate
Content-Type: application/json; charset=utf-8
Date: Wed, 06 May 2015 18:36:47 GMT
ETag: "64b06f52bd0fdd7d7da874379f75c2af"
Server: Apache
Status: 201 Created
X-Content-Type-Options: nosniff
X-Frame-Options: SAMEORIGIN
X-Powered-By: Phusion Passenger 4.0.53
X-Request-Id: 299b653e-18cb-42ed-a2a2-b4df3bc20b6d
X-Runtime: 0.161057
X-XSS-Protection: 1; mode=block
Content-Length: 380
Connection: Close
{"id":"22921ff1-3f5b-4e80-83c2-481f3774b993","account_user_id":"9a10c5c4-4c3d-4f23-9bb9-d95f969a8ac5","project_company_id":"98549b1f-4738-4380-88ce-36096314d032","user_id":"b371c2c5-4928-4210-841b-d451d5bfa315","service_project_id":"60610b3e-7e38-4e83-90f4-beea91b4427a","invite_id":null,"role":null,"created_at":"2015-05-06T18:36:47.572Z","updated_at":"2015-05-06T18:36:47.572Z"}
GET /admin/v1/accounts/6120dc1f-851a-4302-888e-e16f0ef38e24/users?limit=10&offset=0 HTTP/1.1
User-Agent: Faraday v0.9.1
Accept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3
Accept: */*
Connection: close
Host: qa-api.ea.autodesk.com
HTTP/1.1 200 OK
Cache-Control: max-age=0, private, must-revalidate
Content-Type: application/json; charset=utf-8
Date: Wed, 06 May 2015 18:36:47 GMT
ETag: "559639750f64e0ad36938aa58e245fb7"
Server: Apache
Status: 200 OK
X-Content-Type-Options: nosniff
X-Frame-Options: SAMEORIGIN
X-Powered-By: Phusion Passenger 4.0.53
X-Request-Id: c470af31-91eb-41c8-8732-b703c1e4ebfe
X-Runtime: 0.027974
X-XSS-Protection: 1; mode=block
Content-Length: 1239
Connection: Close
[{"id":"b371c2c5-4928-4210-841b-d451d5bfa315","email":"[email protected]","name":"New Member","nickname":null,"first_name":"New","last_name":"Member","uid":null,"image_url":null,"last_sign_in":null,"role":"project_user","address_line_1":null,"address_line_2":null,"city":null,"postal_code":null,"state_or_province":null,"country":null,"phone":null,"company":null,"job_title":null,"industry":null,"about_me":null,"created_at":"2015-05-06 18:36:47.309353","updated_at":"2015-05-06 18:36:47.309353","status":"inactive","status_reason":"pending","company_id":null,"company_name":null},{"id":"eb4e83d9-0727-4a02-992b-4d397f62abc2","email":"[email protected]","name":"New Member","nickname":null,"first_name":"New","last_name":"Member","uid":null,"image_url":null,"last_sign_in":null,"role":"account_admin","address_line_1":null,"address_line_2":null,"city":null,"postal_code":null,"state_or_province":null,"country":null,"phone":null,"company":null,"job_title":null,"industry":null,"about_me":null,"created_at":"2015-05-06 18:36:46.731698","updated_at":"2015-05-06 18:36:46.731698","status":"inactive","status_reason":null,"company_id":null,"company_name":null}]
require "rubygems"
require "bundler"
Bundler.require
HqClient.configure do |config|
config.api_host_name = "http://qa-api.ea.autodesk.com"
config.api_url_base = "/admin/v1"
config.service_type = "field"
end
account_name = "Account #{SecureRandom.uuid}"
account_email = "joe.lind+#{SecureRandom.uuid}@autodesk.com"
email = "joe.lind+#{SecureRandom.uuid}@autodesk.com"
account = HqClient::Account.create(
attributes: {
name: account_name,
display_name: account_name,
category: "paid",
price_model: "enterprise_unlimited",
start_date: '2001-01-01',
end_date: '2021-01-01',
email: account_email,
project_exports_enabled: "true",
user_exports_enabled: "true",
service_types: "field",
corporate_account_name: account_name,
corporate_account_number: account_name
})
# Create 2 projects
project_a = HqClient::Project.create(
account_id: account.id,
attributes: {
name: "Project A",
start_date: account.start_date,
end_date: account.end_date
}
)
project_b = HqClient::Project.create(
account_id: account.id,
attributes: {
name: "Project B",
start_date: account.start_date,
end_date: account.end_date
}
)
# Invite a user by email address to 2 different projects.
#
# NOTE: HQ provides no documented way for a client to specify an of invite ID when we create these invitations, and they returns an `invitation_id` that is null
invited_user = HqClient::ProjectUser.create(
account_id: account.id,
project_id: project_a.id,
company_id: account.company_id,
email: email,
attributes: {}
)
invited_user_2 = HqClient::ProjectUser.create(
account_id: account.id,
project_id: project_b.id,
company_id: account.company_id,
email: email,
attributes: {}
)
# Issue 1: How can we remove one of these invited users from a project? The API only allows us to remove a user by Oxygen ID. Need a mechanism to do this.
# Issue 2: What happens if some other service posts a signup with this same email address. Will HQ post the Oxygen ID to the other services? If so, will it do so by email address?
account_users = HqClient::User.all(account_id: account.id)
puts account_users.inspect
@gwithers
Copy link

gwithers commented May 8, 2015

But we have additional cases as well -- what about when we need to change users in terms of promoting or demoting admin capabilities as well as the delete.

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