Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add missing API key retrieval examples #111

Merged
merged 10 commits into from
Oct 11, 2023
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ go 1.15

require (
github.com/EasyPost/easypost-go/v2 v2.20.0
github.com/EasyPost/easypost-go/v3 v3.0.0
github.com/EasyPost/easypost-go/v3 v3.2.0
)
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ github.com/EasyPost/easypost-go/v2 v2.20.0 h1:DSqpwwTq2XDLg3Nlfk9KSoMHNEyZsqJSyM
github.com/EasyPost/easypost-go/v2 v2.20.0/go.mod h1:+C9K2M4jvFSvN06xYXM2qom4zxmxPDTObQHu++C3hCs=
github.com/EasyPost/easypost-go/v3 v3.0.0 h1:MVyYFFAIJyQdiZFTejmNlIqwaQGeVilQkVyxpwPxutU=
github.com/EasyPost/easypost-go/v3 v3.0.0/go.mod h1:WDD0qkjwxedVKFXCcdJBz22rtRHpuxjGazgSVcTfdIw=
dcaballeroc marked this conversation as resolved.
Show resolved Hide resolved
github.com/EasyPost/easypost-go/v3 v3.2.0 h1:dNWmPG1AkpgYFJxhw/zGzCz1JOVXPpNIi8+JND4UHzk=
github.com/EasyPost/easypost-go/v3 v3.2.0/go.mod h1:WDD0qkjwxedVKFXCcdJBz22rtRHpuxjGazgSVcTfdIw=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/dnaeon/go-vcr v1.2.0/go.mod h1:R4UdLID7HZT3taECzJs4YgbbH6PIGXB6W/sc5OLb6RQ=
Expand Down
6 changes: 6 additions & 0 deletions official/docs/csharp/current/api-keys/retrieve.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,15 @@ public static async Task Main()

var client = new EasyPost.Client(apiKey);

// Retrieve all API keys including children
List<ApiKey> apiKeys = await client.ApiKey.All();

Console.WriteLine(JsonConvert.SerializeObject(apiKeys, Formatting.Indented));

// Retrieve API keys for a specific child user
List<ApiKey> childApiKeys = await client.ApiKey.RetrieveApiKeysForUser("user_...");

Console.WriteLine(JsonConvert.SerializeObject(childApiKeys, Formatting.Indented));
}
}
}
6 changes: 6 additions & 0 deletions official/docs/golang/current/api-keys/retrieve.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,13 @@ func main() {
apiKey := os.Getenv("EASYPOST_API_KEY")
client := easypost.New(apiKey)

// Retrieve all API keys including children
apiKeys, _ := client.GetAPIKeys()

fmt.Println(apiKeys)

// Retrieve API keys for a specific child user
childApiKeys, _ := client.GetAPIKeysForUser("user_...")

fmt.Println(childApiKeys)
}
8 changes: 7 additions & 1 deletion official/docs/java/current/api-keys/retrieve.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,14 @@ public class Retrieve {
public static void main(String[] args) throws EasyPostException {
EasyPostClient client = new EasyPostClient(System.getenv("EASYPOST_API_KEY"));

ApiKeys parentKeys = client.apikeys.all();
// Retrieve all API keys including children
ApiKeys parentKeys = client.apiKey.all();

System.out.println(parentKeys);

// Retrieve API keys for a specific child user
ApiKeys childKeys = client.apiKey.retrieveApiKeysForUser("user_...");

System.out.println(childKeys);
}
}
10 changes: 5 additions & 5 deletions official/docs/node/current/api-keys/retrieve.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ const EasyPostClient = require('@easypost/api');
const client = new EasyPostClient(process.env.EASYPOST_API_KEY);

(async () => {
let apiKeys;

// Retrieve all API keys including children
apiKeys = await client.ApiKey.all();
let apiKeys = await client.ApiKey.all();

console.log(apiKeys);

// Retrieve API keys for a specific child user
apiKeys = await client.User.retrieve('user_...');
let childApiKeys = await client.ApiKey.retrieveApiKeysForUser('user_...');

console.log(apiKeys);
console.log(childApiKeys);
})();
12 changes: 7 additions & 5 deletions official/docs/php/current/api-keys/retrieve.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@

$client = new \EasyPost\EasyPostClient(getenv('EASYPOST_API_KEY'));

// Retrieve all API keys (authenticated user and child user keys)
$apiKeys = $client->user->allApiKeys();
// Retrieve all API keys including children
$apiKeys = $client->apiKeys->all();

// Retrieve API keys for a child user
echo $apiKeys;

// Retrieve API keys for a specific child user
$childUser = $client->user->retrieve('user_...');
dcaballeroc marked this conversation as resolved.
Show resolved Hide resolved
$apiKeys = $client->user->apiKeys($childUser->id);
$childApiKeys = $client->apiKeys->retrieveApiKeysForUser($childUser->id);

echo $apiKeys;
echo $childApiKeys;
12 changes: 7 additions & 5 deletions official/docs/python/current/api-keys/retrieve.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@

client = easypost.EasyPostClient(os.getenv("EASYPOST_API_KEY"))

# Retrieve all API keys (authenticated user and child user keys)
api_keys = client.user.all_api_keys()
# Retrieve all API keys including children
api_keys = client.api_key.all()

# Retrieve API keys for a child user
print(api_keys)

# Retrieve API keys for a specific child user
child_user = client.user.retrieve("user_...")
dcaballeroc marked this conversation as resolved.
Show resolved Hide resolved
api_keys = client.user.api_keys(child_user.id)
child_api_keys = client.api_key.retrieve_api_keys_for_user(child_user.id)

print(api_keys)
print(child_api_keys)
12 changes: 7 additions & 5 deletions official/docs/ruby/current/api-keys/retrieve.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@

client = EasyPost::Client.new(api_key: ENV['EASYPOST_API_KEY'])

# Retrieve all API keys (authenticated user and child user keys)
api_keys = client.user.all_api_keys
# Retrieve all API keys including children
api_keys = client.api_key.all

# Retrieve API keys for a child user
puts api_keys

# Retrieve API keys for a specific child user
child_user = client.user.retrieve('user_...')
dcaballeroc marked this conversation as resolved.
Show resolved Hide resolved
api_keys = client.user.api_keys(child_user.id)
child_api_keys = client.api_key.retrieve_api_keys_for_user(child_user.id)

puts api_keys
puts child_api_keys