Skip to content

Commit

Permalink
Merge pull request #4 from ahtung/feature/show_project_details
Browse files Browse the repository at this point in the history
Feature/show project details
  • Loading branch information
dunyakirkali committed Nov 22, 2018
2 parents 7441213 + 12bdcc6 commit 8d8beed
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
- ~~list enabled LANGUAGES~~
- **Project**
- ~~LIST projects of a project group~~
- SHOW project details
- ~~SHOW project details~~
- CREATE a new project
- UPDATE a project
- DELETE a project
Expand Down
33 changes: 33 additions & 0 deletions fixture/vcr_cassettes/project#show.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
[
{
"request": {
"body": "",
"headers": [],
"method": "get",
"options": [],
"request_body": "",
"url": "https://platform.api.onesky.io/1/projects/314254?api_key=ZE92t9FPVxtoP463kN2B3MYD66eNKu7A&timestamp=1542887100&dev_hash=b652bacdaaf99950b100d8c6b0bfe4f4"
},
"response": {
"binary": false,
"body": "{\"meta\":{\"status\":200},\"data\":{\"id\":314254,\"name\":\"iPhone\\/iPad App\",\"description\":\"\",\"project_type\":{\"code\":\"ios\",\"name\":\"iPhone\\/iPad App\"},\"string_count\":534,\"word_count\":2478}}",
"headers": {
"Access-Control-Allow-Headers": "Authorization, X-Authorization, Origin, Accept, Content-Type, X-Requested-With, X-HTTP-Method-Override",
"Access-Control-Allow-Methods": "PUT, GET, POST, DELETE, OPTIONS",
"Access-Control-Allow-Origin": "*",
"Cache-Control": "no-store, no-cache, must-revalidate, post-check=0, pre-check=0",
"Content-Type": "application/json",
"Date": "Thu, 22 Nov 2018 11:45:00 GMT",
"Expires": "Thu, 19 Nov 1981 08:52:00 GMT",
"Pragma": "no-cache",
"Server": "Apache",
"Set-Cookie": "PHPSESSID=6bckcimmaj6ggqrtla26t32hu5; path=/",
"Vary": "Accept-Encoding",
"Content-Length": "180",
"Connection": "keep-alive"
},
"status_code": 200,
"type": "ok"
}
}
]
7 changes: 7 additions & 0 deletions lib/onesky/resources/project.ex
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,11 @@ defmodule Onesky.Project do
def list_projects(client, project_group_id) do
Tesla.get(client, "/project-groups/#{project_group_id}/projects")
end

@doc """
SHOW project details
"""
def show_project_details(client, project_id) do
Tesla.get(client, "/projects/#{project_id}")
end
end
16 changes: 16 additions & 0 deletions test/onesky/resources/project_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,20 @@ defmodule ProjectTest do
assert length(env.body["data"]) == 3
end
end

test "show_project_details" do
use_cassette "project#show" do
{:ok, %Tesla.Env{} = env} = Onesky.client() |> Onesky.Project.show_project_details(314254)

assert env.status == 200

assert env.body["meta"]["status"] == 200

assert env.body["data"]["id"] == 314254
assert env.body["data"]["name"] == "iPhone/iPad App"
assert env.body["data"]["description"] == ""
assert env.body["data"]["string_count"] == 534
assert env.body["data"]["word_count"] == 2478
end
end
end

0 comments on commit 8d8beed

Please sign in to comment.