postman_mta 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +78 -5
- data/app/controllers/postman_mta/conversations_controller.rb +21 -3
- data/app/controllers/postman_mta/labels_controller.rb +2 -2
- data/app/controllers/postman_mta/messages_controller.rb +2 -2
- data/app/controllers/postman_mta/routes_controller.rb +13 -0
- data/app/controllers/postman_mta/tags_controller.rb +2 -2
- data/app/models/postman_mta/conversation.rb +20 -0
- data/app/models/postman_mta/message.rb +2 -2
- data/app/models/postman_mta/route.rb +7 -0
- data/config/routes.rb +12 -2
- data/lib/postman_mta/api_client.rb +3 -1
- data/lib/postman_mta/version.rb +1 -1
- data/postman_mta.gemspec +1 -1
- metadata +6 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d204a94e4b429c874c194ebcfddbc02969cc92c2
|
4
|
+
data.tar.gz: 4b42a3e90b282fd6a78cbae5153d16f269900776
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 23c96c6b8108320788c4b358be7444f09cfa43f3381dd642eb4d37346bd14f8640e539a57a3811defd8061e652a15d80388e02bd5edbafafd229a6b38982b7cb
|
7
|
+
data.tar.gz: d2e16e3f811071a3654198ae354bd5873f7f4b6d1b9d7ece0c980da317005d9fab13f4bca634eacc7432711190a8088bdf5d9b521b6467df06cdc4c078b00144
|
data/README.md
CHANGED
@@ -1,8 +1,12 @@
|
|
1
|
-
#
|
1
|
+
# Postman MTA
|
2
2
|
|
3
|
-
|
3
|
+
[![Build Status](https://semaphoreci.com/api/v1/igormalinovskiy/postman_mta/branches/master/shields_badge.svg)](https://semaphoreci.com/igormalinovskiy/postman_mta)
|
4
|
+
[![Code Climate](https://codeclimate.com/github/psyipm/postman_mta/badges/gpa.svg)](https://codeclimate.com/github/psyipm/postman_mta)
|
5
|
+
[![Gem Version](https://badge.fury.io/rb/postman_mta.svg)](https://badge.fury.io/rb/postman_mta)
|
4
6
|
|
5
|
-
|
7
|
+
Rails gem to easy integrate Postman to your application
|
8
|
+
|
9
|
+
This gem will add some routes to the application to forward requests from frontend to postman API
|
6
10
|
|
7
11
|
## Installation
|
8
12
|
|
@@ -22,7 +26,76 @@ Or install it yourself as:
|
|
22
26
|
|
23
27
|
## Usage
|
24
28
|
|
25
|
-
|
29
|
+
Mount engine in `config/routes.rb`:
|
30
|
+
|
31
|
+
```ruby
|
32
|
+
mount PostmanMta::Engine => '/mta'
|
33
|
+
```
|
34
|
+
|
35
|
+
Then configure the gem:
|
36
|
+
|
37
|
+
```ruby
|
38
|
+
# config/initializers/postman_mta.rb
|
39
|
+
PostmanMta.setup do |config|
|
40
|
+
config.api_key = ENV['POSTMAN_API_KEY']
|
41
|
+
config.api_secret = ENV['POSTMAN_API_SECRET']
|
42
|
+
config.api_endpoint = ENV['POSTMAN_API_ENDPOINT']
|
43
|
+
end
|
44
|
+
```
|
45
|
+
|
46
|
+
This will add the following routes:
|
47
|
+
|
48
|
+
```
|
49
|
+
Routes for PostmanMta::Engine:
|
50
|
+
messages POST /messages(.:format) postman_mta/messages#create
|
51
|
+
message GET /messages/:id(.:format) postman_mta/messages#show
|
52
|
+
conversation_labels POST /conversations/:conversation_id/labels(.:format) postman_mta/labels#create
|
53
|
+
conversation_label DELETE /conversations/:conversation_id/labels/:id(.:format) postman_mta/labels#destroy
|
54
|
+
conversation_tags POST /conversations/:conversation_id/tags(.:format) postman_mta/tags#create
|
55
|
+
conversation_tag DELETE /conversations/:conversation_id/tags/:id(.:format) postman_mta/tags#destroy
|
56
|
+
conversations GET /conversations(.:format) postman_mta/conversations#index
|
57
|
+
conversation GET /conversations/:id(.:format) postman_mta/conversations#show
|
58
|
+
```
|
59
|
+
|
60
|
+
for `messages#create` the following parameters accepted:
|
61
|
+
|
62
|
+
```ruby
|
63
|
+
attribute :from, String
|
64
|
+
attribute :to, Array # The array of recepient email addresses
|
65
|
+
attribute :plain_body, String
|
66
|
+
attribute :html_body, String
|
67
|
+
attribute :bcc, Array # The array of bcc email addresses
|
68
|
+
attribute :cc, Array # The array of cc email addresses
|
69
|
+
attribute :reply_to, String
|
70
|
+
attribute :in_reply_to, String
|
71
|
+
attribute :subject, String
|
72
|
+
attribute :attachments, Array # [{ base64: "YXNmYXNmYXNm\n", name: 'file.txt', content_type: 'text/plain' }]
|
73
|
+
```
|
74
|
+
|
75
|
+
Messages are grouped in conversations. Conversations can be accessed using corresponding `#index` and `#show` actions.
|
76
|
+
|
77
|
+
Filter parameters for `conversations#index`:
|
78
|
+
|
79
|
+
```ruby
|
80
|
+
{ tag_title: 'some_tag', tag_value: 'some_value' }
|
81
|
+
{ label: 'some_label_title' }
|
82
|
+
```
|
83
|
+
|
84
|
+
Conversations can be tagged and/or labeled. Labels and tags can be used for search. To create new tag for conversation, send the following params to `tags#create`:
|
85
|
+
|
86
|
+
```ruby
|
87
|
+
attribute :title, String
|
88
|
+
attribute :value, String
|
89
|
+
attribute :conversation_id, Integer
|
90
|
+
```
|
91
|
+
|
92
|
+
Params for label:
|
93
|
+
|
94
|
+
```ruby
|
95
|
+
attribute :title, String
|
96
|
+
attribute :sort_order, Integer
|
97
|
+
attribute :color, String
|
98
|
+
```
|
26
99
|
|
27
100
|
## Development
|
28
101
|
|
@@ -32,7 +105,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
32
105
|
|
33
106
|
## Contributing
|
34
107
|
|
35
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
108
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/psyipm/postman_mta.
|
36
109
|
|
37
110
|
## License
|
38
111
|
|
@@ -1,11 +1,29 @@
|
|
1
1
|
module PostmanMta
|
2
2
|
class ConversationsController < ApplicationController
|
3
3
|
def index
|
4
|
-
render
|
4
|
+
render conversation.index(permitted_params)
|
5
|
+
end
|
6
|
+
|
7
|
+
[:inbox, :sent, :spam, :trash].each do |folder|
|
8
|
+
define_method folder do
|
9
|
+
render conversation.folder(folder, permitted_params)
|
10
|
+
end
|
5
11
|
end
|
6
12
|
|
7
13
|
def show
|
8
|
-
render
|
14
|
+
render conversation.find(params[:id])
|
15
|
+
end
|
16
|
+
|
17
|
+
def read
|
18
|
+
render conversation.mark_as_read(permitted_params)
|
19
|
+
end
|
20
|
+
|
21
|
+
def destroy
|
22
|
+
render conversation.move_to_trash(params[:id])
|
23
|
+
end
|
24
|
+
|
25
|
+
def move
|
26
|
+
render conversation.move(permitted_params)
|
9
27
|
end
|
10
28
|
|
11
29
|
private
|
@@ -14,7 +32,7 @@ module PostmanMta
|
|
14
32
|
@conversation ||= PostmanMta::Conversation.new
|
15
33
|
end
|
16
34
|
|
17
|
-
def
|
35
|
+
def permitted_params
|
18
36
|
params.permit!
|
19
37
|
end
|
20
38
|
end
|
@@ -1,11 +1,11 @@
|
|
1
1
|
module PostmanMta
|
2
2
|
class LabelsController < ApplicationController
|
3
3
|
def create
|
4
|
-
render
|
4
|
+
render label.create(label_params)
|
5
5
|
end
|
6
6
|
|
7
7
|
def destroy
|
8
|
-
render
|
8
|
+
render label.destroy(params[:id])
|
9
9
|
end
|
10
10
|
|
11
11
|
private
|
@@ -1,11 +1,11 @@
|
|
1
1
|
module PostmanMta
|
2
2
|
class MessagesController < ApplicationController
|
3
3
|
def show
|
4
|
-
render
|
4
|
+
render message.find(params[:token])
|
5
5
|
end
|
6
6
|
|
7
7
|
def create
|
8
|
-
render
|
8
|
+
render message.create(message_params)
|
9
9
|
end
|
10
10
|
|
11
11
|
private
|
@@ -1,11 +1,11 @@
|
|
1
1
|
module PostmanMta
|
2
2
|
class TagsController < ApplicationController
|
3
3
|
def create
|
4
|
-
render
|
4
|
+
render tag.create(tag_params)
|
5
5
|
end
|
6
6
|
|
7
7
|
def destroy
|
8
|
-
render
|
8
|
+
render tag.destroy(params[:id])
|
9
9
|
end
|
10
10
|
|
11
11
|
private
|
@@ -4,8 +4,28 @@ module PostmanMta
|
|
4
4
|
get('/api/v1/conversations', body: params)
|
5
5
|
end
|
6
6
|
|
7
|
+
def folder(folder, params = {})
|
8
|
+
params = {
|
9
|
+
folder: folder
|
10
|
+
}.merge(params)
|
11
|
+
|
12
|
+
get('/api/v1/conversations', body: params)
|
13
|
+
end
|
14
|
+
|
7
15
|
def find(conversation_id)
|
8
16
|
get("/api/v1/conversations/#{conversation_id}")
|
9
17
|
end
|
18
|
+
|
19
|
+
def move_to_trash(conversation_id)
|
20
|
+
delete("/api/v1/conversations/#{conversation_id}/trash")
|
21
|
+
end
|
22
|
+
|
23
|
+
def mark_as_read(params = {})
|
24
|
+
patch('/api/v1/conversations/read', body: params)
|
25
|
+
end
|
26
|
+
|
27
|
+
def move(params = {})
|
28
|
+
patch('/api/v1/conversations/move', body: params)
|
29
|
+
end
|
10
30
|
end
|
11
31
|
end
|
data/config/routes.rb
CHANGED
@@ -1,8 +1,18 @@
|
|
1
1
|
PostmanMta::Engine.routes.draw do
|
2
|
-
resources :messages, only: [:show, :create]
|
2
|
+
resources :messages, only: [:show, :create], param: :token
|
3
|
+
|
4
|
+
resources :conversations, only: [:index, :show, :destroy] do
|
5
|
+
[:inbox, :sent, :spam, :trash].each do |folder|
|
6
|
+
match folder, on: :collection, via: :get
|
7
|
+
end
|
8
|
+
|
9
|
+
match :starred, on: :collection, via: :get, to: 'conversations#index'
|
10
|
+
match :read, on: :collection, via: [:put, :patch]
|
11
|
+
match :move, on: :collection, via: [:put, :patch]
|
3
12
|
|
4
|
-
resources :conversations, only: [:index, :show] do
|
5
13
|
resources :labels, only: [:create, :destroy]
|
6
14
|
resources :tags, only: [:create, :destroy]
|
7
15
|
end
|
16
|
+
|
17
|
+
resources :routes, only: :index
|
8
18
|
end
|
@@ -18,7 +18,9 @@ module PostmanMta
|
|
18
18
|
request_method: request_type.upcase, path: path
|
19
19
|
).headers
|
20
20
|
|
21
|
-
self.class.send(request_type.downcase, path, { headers: headers }.merge(options))
|
21
|
+
response = self.class.send(request_type.downcase, path, { headers: headers }.merge(options))
|
22
|
+
|
23
|
+
{ json: response.parsed_response.as_json, status: response.code }
|
22
24
|
end
|
23
25
|
end
|
24
26
|
end
|
data/lib/postman_mta/version.rb
CHANGED
data/postman_mta.gemspec
CHANGED
@@ -23,7 +23,7 @@ Gem::Specification.new do |spec|
|
|
23
23
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
24
24
|
spec.require_paths = ['lib']
|
25
25
|
|
26
|
-
spec.add_development_dependency 'bundler', '~> 1.
|
26
|
+
spec.add_development_dependency 'bundler', '~> 1.14'
|
27
27
|
spec.add_development_dependency 'guard-rspec', '~> 4.7', '>= 4.7.3'
|
28
28
|
spec.add_development_dependency 'rake', '~> 10.0'
|
29
29
|
spec.add_development_dependency 'reek'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: postman_mta
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Igor Malinovskiy
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-09-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '1.
|
19
|
+
version: '1.14'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '1.
|
26
|
+
version: '1.14'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: guard-rspec
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -122,11 +122,13 @@ files:
|
|
122
122
|
- app/controllers/postman_mta/conversations_controller.rb
|
123
123
|
- app/controllers/postman_mta/labels_controller.rb
|
124
124
|
- app/controllers/postman_mta/messages_controller.rb
|
125
|
+
- app/controllers/postman_mta/routes_controller.rb
|
125
126
|
- app/controllers/postman_mta/tags_controller.rb
|
126
127
|
- app/models/postman_mta/application_model.rb
|
127
128
|
- app/models/postman_mta/conversation.rb
|
128
129
|
- app/models/postman_mta/label.rb
|
129
130
|
- app/models/postman_mta/message.rb
|
131
|
+
- app/models/postman_mta/route.rb
|
130
132
|
- app/models/postman_mta/tag.rb
|
131
133
|
- bin/console
|
132
134
|
- bin/setup
|