From 910b62694562c346b629e8f1c9ee681c5ebda683 Mon Sep 17 00:00:00 2001 From: Craig Paterson Date: Fri, 4 Mar 2016 08:21:11 +0200 Subject: [PATCH] fixes --- LICENSE | 2 +- README.md | 4 ++-- lib/gmail.ex | 6 +++--- lib/gmail/oauth2.ex | 2 +- mix.exs | 17 +++++++++-------- mix.lock | 14 +++++++------- test/gmail/message_test.exs | 12 ++++-------- test/gmail/thread_test.exs | 15 +++++---------- 8 files changed, 32 insertions(+), 40 deletions(-) diff --git a/LICENSE b/LICENSE index 785fbb4..c5edc16 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) [year] [fullname] +Copyright (c) 2016 Craig Paterson Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md index a910e6b..8364c27 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ elixir-gmail [![hex.pm downloads](https://img.shields.io/hexpm/dt/gmail.svg)](https://hex.pm/packages/gmail) [![Inline docs](http://inch-ci.org/github/craigp/elixir-gmail.svg?branch=master&style=flat)](http://inch-ci.org/github/craigp/elixir-gmail) -A simple Gmail REST API client for Elixir, mostly built as a learning exercise. +A simple Gmail REST API client for Elixir. You can find the hex package [here](https://hex.pm/packages/gmail), and the docs [here](http://hexdocs.pm/gmail). @@ -18,7 +18,7 @@ First, add the client to your `mix.exs` dependencies: ```elixir def deps do - [{:gmail, "~> 0.0.17"}] + [{:gmail, "~> 0.1"}] end ``` diff --git a/lib/gmail.ex b/lib/gmail.ex index cc8c7d8..846d937 100644 --- a/lib/gmail.ex +++ b/lib/gmail.ex @@ -1,7 +1,7 @@ defmodule Gmail do @moduledoc """ - A simple Gmail REST API client for Elixir, mostly built as a learning exercise. + A simple Gmail REST API client for Elixir. You can find the hex package [here](https://hex.pm/packages/gmail), and the docs [here](http://hexdocs.pm/gmail). @@ -13,7 +13,7 @@ defmodule Gmail do ```elixir def deps do - [{:gmail, "~> 0.0.17"}] + [{:gmail, "~> 0.0.17"}] end ``` @@ -23,7 +23,7 @@ defmodule Gmail do ```elixir def application do - [applications: [:logger, :gmail]] + [applications: [:logger, :gmail]] end ``` diff --git a/lib/gmail/oauth2.ex b/lib/gmail/oauth2.ex index 30d890d..4ed6e83 100644 --- a/lib/gmail/oauth2.ex +++ b/lib/gmail/oauth2.ex @@ -19,7 +19,7 @@ defmodule Gmail.OAuth2 do @type t :: %__MODULE__{} - @auth_url "https://accounts.google.com/o/oauth2/auth" + # @auth_url "https://accounts.google.com/o/oauth2/auth" @token_url "https://accounts.google.com/o/oauth2/token" @token_headers %{"Content-Type" => "application/x-www-form-urlencoded"} @scope "https://mail.google.com/" diff --git a/mix.exs b/mix.exs index 227fbb3..756cee1 100644 --- a/mix.exs +++ b/mix.exs @@ -3,12 +3,12 @@ defmodule Gmail.Mixfile do def project do [app: :gmail, - version: "0.0.18", + version: "0.1.0", elixir: "~> 1.2", deps: deps, test_coverage: [tool: ExCoveralls], preferred_cli_env: ["coveralls": :test, "coveralls.detail": :test, "coveralls.post": :test], - description: "A simple Gmail REST API client for Elixir, mostly built as a learning exercise", + description: "A simple Gmail REST API client for Elixir", package: package] end @@ -20,16 +20,16 @@ defmodule Gmail.Mixfile do defp deps do [ {:httpoison, "~> 0.8"}, - {:poison, "~> 1.5"}, - {:timex, "~> 0.19"}, + {:poison, "~> 2.1"}, + {:timex, "~> 1.0"}, {:mock, "~> 0.1", only: :test}, - {:excoveralls, "~> 0.4", only: :test}, + {:excoveralls, "~> 0.5", only: :test}, {:earmark, "~> 0.2", only: :dev}, {:ex_doc, "~> 0.11", only: :dev}, {:dialyxir, "~> 0.3", only: :dev}, - {:credo, "~> 0.2", only: :dev}, + {:credo, "~> 0.3", only: :dev}, {:bypass, "~> 0.1", only: :test}, - {:inch_ex, only: :docs} + {:inch_ex, "~> 0.5", only: :docs} ] end @@ -39,7 +39,8 @@ defmodule Gmail.Mixfile do files: ["lib", "mix.exs", "README*"], licenses: ["MIT"], maintainers: ["Craig Paterson"], - links: %{"Github" => "https://github.com/craigp/elixir-gmail"}] + links: %{"Github" => "https://github.com/craigp/elixir-gmail"} + ] end end diff --git a/mix.lock b/mix.lock index a77d4a5..17a148d 100644 --- a/mix.lock +++ b/mix.lock @@ -1,4 +1,4 @@ -%{"bunt": {:hex, :bunt, "0.1.4"}, +%{"bunt": {:hex, :bunt, "0.1.5"}, "bypass": {:hex, :bypass, "0.5.1"}, "certifi": {:hex, :certifi, "0.3.0"}, "combine": {:hex, :combine, "0.7.0"}, @@ -8,19 +8,19 @@ "dialyxir": {:hex, :dialyxir, "0.3.3"}, "earmark": {:hex, :earmark, "0.2.1"}, "ex_doc": {:hex, :ex_doc, "0.11.4"}, - "excoveralls": {:hex, :excoveralls, "0.4.6"}, + "excoveralls": {:hex, :excoveralls, "0.5.1"}, "exjsx": {:hex, :exjsx, "3.2.0"}, - "hackney": {:hex, :hackney, "1.4.8"}, + "hackney": {:hex, :hackney, "1.4.10"}, "httpoison": {:hex, :httpoison, "0.8.1"}, - "idna": {:hex, :idna, "1.0.3"}, + "idna": {:hex, :idna, "1.1.0"}, "inch_ex": {:hex, :inch_ex, "0.5.1"}, "jsx": {:hex, :jsx, "2.6.2"}, "meck": {:hex, :meck, "0.8.4"}, "mimerl": {:hex, :mimerl, "1.0.2"}, "mock": {:hex, :mock, "0.1.1"}, - "plug": {:hex, :plug, "1.1.1"}, - "poison": {:hex, :poison, "1.5.2"}, + "plug": {:hex, :plug, "1.1.2"}, + "poison": {:hex, :poison, "2.1.0"}, "ranch": {:hex, :ranch, "1.2.1"}, "ssl_verify_hostname": {:hex, :ssl_verify_hostname, "1.0.5"}, - "timex": {:hex, :timex, "0.19.5"}, + "timex": {:hex, :timex, "1.0.2"}, "tzdata": {:hex, :tzdata, "0.5.6"}} diff --git a/test/gmail/message_test.exs b/test/gmail/message_test.exs index b16c6ad..8222ccc 100644 --- a/test/gmail/message_test.exs +++ b/test/gmail/message_test.exs @@ -110,9 +110,8 @@ defmodule Gmail.MessageTest do bypass: bypass } do email = "user@example.com" - email_encoded = "user%40example.com" # for some reason URI.encode/1 doesn't encode the @ Bypass.expect bypass, fn conn -> - assert "/gmail/v1/users/#{email_encoded}/messages/#{message_id}" == conn.request_path + assert "/gmail/v1/users/#{email}/messages/#{message_id}" == conn.request_path assert "format=full" == conn.query_string {:ok, json} = Poison.encode(message) Plug.Conn.resp(conn, 200, json) @@ -131,9 +130,8 @@ defmodule Gmail.MessageTest do message_not_found: message_not_found } do email = "user@example.com" - email_encoded = "user%40example.com" # for some reason URI.encode/1 doesn't encode the @ Bypass.expect bypass, fn conn -> - assert "/gmail/v1/users/#{email_encoded}/messages/#{message_id}" == conn.request_path + assert "/gmail/v1/users/#{email}/messages/#{message_id}" == conn.request_path assert "format=full" == conn.query_string {:ok, json} = Poison.encode(message_not_found) Plug.Conn.resp(conn, 200, json) @@ -151,9 +149,8 @@ defmodule Gmail.MessageTest do four_hundred_error: four_hundred_error } do email = "user@example.com" - email_encoded = "user%40example.com" # for some reason URI.encode/1 doesn't encode the @ Bypass.expect bypass, fn conn -> - assert "/gmail/v1/users/#{email_encoded}/messages/#{message_id}" == conn.request_path + assert "/gmail/v1/users/#{email}/messages/#{message_id}" == conn.request_path assert "format=full" == conn.query_string {:ok, json} = Poison.encode(four_hundred_error) Plug.Conn.resp(conn, 200, json) @@ -192,9 +189,8 @@ defmodule Gmail.MessageTest do bypass: bypass } do email = "user@example.com" - email_encoded = "user%40example.com" # for some reason URI.encode/1 doesn't encode the @ Bypass.expect bypass, fn conn -> - assert "/gmail/v1/users/#{email_encoded}/messages" == conn.request_path + assert "/gmail/v1/users/#{email}/messages" == conn.request_path assert "q=in:Inbox" == conn.query_string {:ok, json} = Poison.encode(%{"messages" => [message]}) Plug.Conn.resp(conn, 200, json) diff --git a/test/gmail/thread_test.exs b/test/gmail/thread_test.exs index aa79bef..0b19861 100644 --- a/test/gmail/thread_test.exs +++ b/test/gmail/thread_test.exs @@ -136,9 +136,8 @@ defmodule Gmail.ThreadTest do expected_result: expected_result } do email = "user@example.com" - email_encoded = "user%40example.com" # for some reason URI.encode/1 doesn't encode the @ Bypass.expect bypass, fn conn -> - assert "/gmail/v1/users/#{email_encoded}/threads/#{thread_id}" == conn.request_path + assert "/gmail/v1/users/#{email}/threads/#{thread_id}" == conn.request_path assert "format=full" == conn.query_string assert "GET" == conn.method assert {"authorization", "Bearer #{access_token}"} in conn.req_headers @@ -211,10 +210,9 @@ defmodule Gmail.ThreadTest do access_token_rec: access_token_rec, } do email = "user@example.com" - email_encoded = "user%40example.com" # for some reason URI.encode/1 doesn't encode the @ query = "in:Inbox" Bypass.expect bypass, fn conn -> - assert "/gmail/v1/users/#{email_encoded}/threads" == conn.request_path + assert "/gmail/v1/users/#{email}/threads" == conn.request_path assert "q=#{query}" == conn.query_string {:ok, json} = Poison.encode(search_results) Plug.Conn.resp(conn, 200, json) @@ -255,9 +253,8 @@ defmodule Gmail.ThreadTest do threads: threads } do email = "user@example.com" - email_encoded = "user%40example.com" # for some reason URI.encode/1 doesn't encode the @ Bypass.expect bypass, fn conn -> - assert "/gmail/v1/users/#{email_encoded}/threads" == conn.request_path + assert "/gmail/v1/users/#{email}/threads" == conn.request_path assert "" == conn.query_string {:ok, json} = Poison.encode(threads) Plug.Conn.resp(conn, 200, json) @@ -278,10 +275,9 @@ defmodule Gmail.ThreadTest do next_page_token: next_page_token } do email = "user@example.com" - email_encoded = "user%40example.com" # for some reason URI.encode/1 doesn't encode the @ requested_page_token = "435453455" Bypass.expect bypass, fn conn -> - assert "/gmail/v1/users/#{email_encoded}/threads" == conn.request_path + assert "/gmail/v1/users/#{email}/threads" == conn.request_path assert "pageToken=#{requested_page_token}" == conn.query_string {:ok, json} = Poison.encode(threads) Plug.Conn.resp(conn, 200, json) @@ -302,9 +298,8 @@ defmodule Gmail.ThreadTest do threads: threads } do email = "user@example.com" - email_encoded = "user%40example.com" # for some reason URI.encode/1 doesn't encode the @ Bypass.expect bypass, fn conn -> - assert "/gmail/v1/users/#{email_encoded}/threads" == conn.request_path + assert "/gmail/v1/users/#{email}/threads" == conn.request_path assert "" == conn.query_string {:ok, json} = Poison.encode(threads) Plug.Conn.resp(conn, 200, json)