Skip to content

Commit

Permalink
Merge pull request #19 from ahtung/feature/screenshot
Browse files Browse the repository at this point in the history
Feature/screenshot
  • Loading branch information
dunyakirkali committed Jan 1, 2020
2 parents 60cff49 + 0249c0c commit 635c960
Show file tree
Hide file tree
Showing 7 changed files with 76 additions and 5 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ config :onesky,
- ~~LIST import tasks~~
- ~~SHOW import task~~
- **Screenshot**
- UPLOAD screenshots
- ~~UPLOAD screenshots~~

**Order**
- **Quotation**
Expand Down
Binary file added fixture/screenshots/screenshot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
32 changes: 32 additions & 0 deletions fixture/vcr_cassettes/screenshots#upload.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
[
{
"request": {
"body": "",
"headers": [],
"method": "post",
"options": [],
"request_body": "",
"url": "https://platform.api.onesky.io/1/projects/314254/screenshots?api_key=.*&timestamp=.*&dev_hash=.*"
},
"response": {
"binary": false,
"body": "",
"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": "Wed, 21 Nov 2018 21:05:08 GMT",
"Expires": "Thu, 19 Nov 1981 08:52:00 GMT",
"Pragma": "no-cache",
"Server": "Apache",
"Set-Cookie": "PHPSESSID=un76cfch89c2b9kou1717arou3; path=/",
"Content-Length": "83",
"Connection": "keep-alive"
},
"status_code": 201,
"type": "ok"
}
}
]
12 changes: 12 additions & 0 deletions lib/onesky/resources/screenshot.ex
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
defmodule Onesky.Screenshot do
@moduledoc """
[Screenshot](https://github.com/onesky/api-documentation-platform/blob/master/resources/screenshot.md)
"""

@doc """
UPLOAD screenshots
"""
def upload_screenshots(client, project_id, screenshots) do
Tesla.post(client, "projects/#{project_id}/screenshots", screenshots)
end
end
2 changes: 0 additions & 2 deletions test/onesky/resources/file_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ defmodule FileTest do
use ExUnit.Case, async: true
use ExVCR.Mock, adapter: ExVCR.Adapter.Hackney

alias Tesla.Multipart

doctest Onesky.File

test "list_uploaded_files" do
Expand Down
31 changes: 31 additions & 0 deletions test/onesky/resources/screenshot_test.exs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
defmodule ScreenshotTest do
use ExUnit.Case, async: true
use ExVCR.Mock, adapter: ExVCR.Adapter.Hackney

doctest Onesky.Screenshot

test "upload_screenshots" do
use_cassette "screenshots#upload" do
image = "fixture/screenshots/screenshot.png" |> File.read! |> Base.encode64()
screenshots = [
%{
"name" => "screenshot.png",
"image" => image,
"tags" => [
%{
"key" => "common.nav.product.smartphone",
"x" => 460,
"y" => 30,
"width" => 150,
"height" => 50,
"file" => "string.po"
}
]
}
]
{:ok, %Tesla.Env{} = env} = Onesky.client() |> Onesky.Screenshot.upload_screenshots(314254, screenshots)

assert env.status == 201
end
end
end
2 changes: 0 additions & 2 deletions test/onesky/resources/translation_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ defmodule TranslationTest do
use ExUnit.Case, async: true
use ExVCR.Mock, adapter: ExVCR.Adapter.Hackney

alias Tesla.Multipart

doctest Onesky.Translation

test "get_appstore_description" do
Expand Down

0 comments on commit 635c960

Please sign in to comment.