You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- Go to https://hexdocs.pm/hex/Mix.Tasks.Hex.html and find what you want to do
7
+
2. Once you find the page, click on the code icon on the top-right to go to the corresponding source code like so: https://github.com/hexpm/hex/blob/main/lib/mix/tasks/hex.owner.ex#L125
8
+
```elixir
9
+
defptransfer_owner(organization, package, owner) do
10
+
auth =Mix.Tasks.Hex.auth_info(:write)
11
+
Hex.Shell.info("Transferring ownership to #{owner} for #{package}")
12
+
13
+
caseHex.API.Package.Owner.add(organization, package, owner, "full", true, auth) do
14
+
{:ok, {code, _body, _headers}} when code in200..299->
15
+
:ok
16
+
17
+
other ->
18
+
Hex.Shell.error("Transferring ownership failed")
19
+
Hex.Utils.print_error_result(other)
20
+
end
21
+
end
22
+
```
23
+
24
+
3. The API function this is calling is `Hex.API.Package.Owner.add` so we go to https://github.com/hexpm/hex/blob/main/lib/hex/api/package.ex, scroll down to the defmodule for Owner and then find the `add` function:
25
+
```elixir
26
+
defadd(repo, package, owner, level, transfer, auth) when package !=""do
`path` tells us what path and variables we will be using while `params` tells us what the body of the request should contain. The `API.erlang_put_request` at the bottom of this tells us the method of our request needs to be `PUT`. Now we have all of the information we need to create our request function like so:
Note that the `api_key` and `config` fields will always be present in these request functions while the other fields are tailored to the specific request we want to make.
59
+
60
+
4. TODO: How to figure out what to write for the response function?
0 commit comments