postman_mta 0.2.1 → 0.2.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2d9293f93f017dfa88b6077c19fd05b3969669891e2649bf1dced1d4e5429869
4
- data.tar.gz: 3822ea0ec147420749580b24d00d41e8a12ac38359c1ab6fa8fb39958cd8a7df
3
+ metadata.gz: b3f31a356898b343aa8766df4f375eb7cd2e5e470c13d5adaeb4156f519508a7
4
+ data.tar.gz: b74c5015fd4fe03396bedafbeee6c9b5ef1d2a917bd5b6288d98fd249a1ab336
5
5
  SHA512:
6
- metadata.gz: 6e2d0a4827f7f147cf1e1f1063ae96e68cab8f87befaf8b1df8518e38a62da210c65c490dc42d2d21870f229109b70c9206148805d34aac532ed6062ee613246
7
- data.tar.gz: 4e10279361370373e0ac372833d05328ab8b0b1060aa3d51ea94d23f21c9835e4761c4ba9603a1f862a4b87fb859cbb05ed8fbf99c8561e5666d6e737ec44aba
6
+ metadata.gz: 7d6c3594c6cf17d4d49bc2001956c9d74a7ebad3e2d7d8398991bebce0d8513e45b00ccd87c61971b2e0050731f9c5aab91ee1df3ad16c37d6fd9497f6a60fb3
7
+ data.tar.gz: 367ce072be4a984bba7882983bfabfadc014afff2e05d68bbeee5510f80798d0430c0e92d789b81ba09c8bb417510291d51e7d7fd51a4f65cae9f1937b0edd19
data/.rubocop.yml CHANGED
@@ -1,6 +1,6 @@
1
1
  AllCops:
2
+ NewCops: disable
2
3
  TargetRubyVersion: 2.4
3
-
4
4
  Exclude:
5
5
  - "Guardfile"
6
6
  - "Rakefile"
@@ -30,7 +30,7 @@ Lint/AmbiguousBlockAssociation:
30
30
 
31
31
  ##################### Metrics ##################################
32
32
 
33
- Metrics/LineLength:
33
+ Layout/LineLength:
34
34
  Max: 110
35
35
 
36
36
  Metrics/ClassLength:
@@ -45,11 +45,3 @@ Metrics/BlockLength:
45
45
  Max: 50
46
46
  Exclude:
47
47
  - "**/*_spec.rb"
48
-
49
- ##################### Rails ##################################
50
-
51
- Rails:
52
- Enabled: true
53
-
54
- Rails/SkipsModelValidations:
55
- Enabled: false
@@ -0,0 +1,27 @@
1
+ module PostmanMta
2
+ module Archive
3
+ class ConversationsController < ApplicationController
4
+ def index
5
+ render conversation.index(permitted_params)
6
+ end
7
+
8
+ def show
9
+ render conversation.find(params[:id])
10
+ end
11
+
12
+ def move
13
+ render conversation.move(permitted_params)
14
+ end
15
+
16
+ private
17
+
18
+ def conversation
19
+ @conversation ||= PostmanMta::Archive::Conversation.new
20
+ end
21
+
22
+ def permitted_params
23
+ params.permit!
24
+ end
25
+ end
26
+ end
27
+ end
@@ -5,6 +5,7 @@ module PostmanMta
5
5
  def show
6
6
  response = attachment.find(params[:uuid]).deep_symbolize_keys
7
7
  file = response.dig(:json, :attachment)
8
+ raise(PostmanMta::RecordNotFound, "Attachment via id #{params[:uuid]} not found") unless file
8
9
 
9
10
  if file[:body].present?
10
11
  send_attachment(file)
@@ -0,0 +1,21 @@
1
+ module PostmanMta
2
+ class NotesController < ApplicationController
3
+ def create
4
+ render note.create(notes_params)
5
+ end
6
+
7
+ def update
8
+ render note.update(notes_params[:id], notes_params)
9
+ end
10
+
11
+ private
12
+
13
+ def note
14
+ @note ||= PostmanMta::Note.new
15
+ end
16
+
17
+ def notes_params
18
+ params.permit!
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,17 @@
1
+ module PostmanMta
2
+ module Archive
3
+ class Conversation < PostmanMta::Conversation
4
+ def index(params = {})
5
+ get('/archive/conversations', body: params)
6
+ end
7
+
8
+ def find(conversation_id)
9
+ get("/archive/conversations/#{conversation_id}")
10
+ end
11
+
12
+ def move(params = {})
13
+ patch('/archive/conversations/move', body: params)
14
+ end
15
+ end
16
+ end
17
+ end
@@ -4,10 +4,14 @@ module PostmanMta
4
4
  get('/conversations', body: params)
5
5
  end
6
6
 
7
+ def archive(params = {})
8
+ get('/archive/conversations', body: params)
9
+ end
10
+
7
11
  def folder(folder, params = {})
8
12
  params = {
9
13
  folder: folder
10
- }.merge(params)
14
+ }.merge!(params)
11
15
 
12
16
  get('/conversations', body: params)
13
17
  end
@@ -0,0 +1,11 @@
1
+ module PostmanMta
2
+ class Note < ApplicationModel
3
+ def create(params)
4
+ post('/notes', body: params)
5
+ end
6
+
7
+ def update(note_id, params)
8
+ patch("/notes/#{note_id}", body: params)
9
+ end
10
+ end
11
+ end
@@ -11,5 +11,9 @@ module PostmanMta
11
11
  def create(params = {})
12
12
  post('/routes', body: params)
13
13
  end
14
+
15
+ def destroy(uuid, params = {})
16
+ delete("/routes/#{uuid}", body: params)
17
+ end
14
18
  end
15
19
  end
data/config/routes.rb CHANGED
@@ -24,7 +24,14 @@ PostmanMta::Engine.routes.draw do
24
24
  end
25
25
  end
26
26
 
27
+ namespace :archive do
28
+ resources :conversations, only: [:index, :show] do
29
+ match :move, on: :collection, via: [:put, :patch]
30
+ end
31
+ end
32
+
27
33
  resources :routes, only: :index
28
34
  resources :domains, only: :index
29
35
  resources :labels, only: :index
36
+ resources :notes, only: [:create, :update]
30
37
  end
data/lib/postman_mta.rb CHANGED
@@ -10,6 +10,7 @@ module PostmanMta
10
10
 
11
11
  autoload :ApiClient, 'postman_mta/api_client'
12
12
  autoload :ApiRequest, 'postman_mta/api_request'
13
+ autoload :RecordNotFound, 'postman_mta/record_not_found'
13
14
 
14
15
  mattr_accessor :api_key
15
16
  mattr_accessor :api_secret
@@ -17,7 +17,7 @@ module PostmanMta
17
17
  @response_body = response.parsed_response
18
18
  @response_status = response.code
19
19
 
20
- { json: response_body, status: response_status }
20
+ { json: response_body, status: @response_status }
21
21
  end
22
22
  end
23
23
  end
@@ -0,0 +1,3 @@
1
+ module PostmanMta
2
+ class RecordNotFound < StandardError; end
3
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module PostmanMta
4
- VERSION = '0.2.1'
4
+ VERSION = '0.2.7'
5
5
  end
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.2.1
4
+ version: 0.2.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Igor Malinovskiy
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-03-14 00:00:00.000000000 Z
11
+ date: 2021-05-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -148,15 +148,18 @@ files:
148
148
  - README.md
149
149
  - Rakefile
150
150
  - app/controllers/postman_mta/application_controller.rb
151
+ - app/controllers/postman_mta/archive/conversations_controller.rb
151
152
  - app/controllers/postman_mta/attachments_controller.rb
152
153
  - app/controllers/postman_mta/conversations_controller.rb
153
154
  - app/controllers/postman_mta/domains_controller.rb
154
155
  - app/controllers/postman_mta/labels_controller.rb
155
156
  - app/controllers/postman_mta/messages_controller.rb
157
+ - app/controllers/postman_mta/notes_controller.rb
156
158
  - app/controllers/postman_mta/routes_controller.rb
157
159
  - app/controllers/postman_mta/stats/messages_controller.rb
158
160
  - app/controllers/postman_mta/tags_controller.rb
159
161
  - app/models/postman_mta/application_model.rb
162
+ - app/models/postman_mta/archive/conversation.rb
160
163
  - app/models/postman_mta/attachment.rb
161
164
  - app/models/postman_mta/bookmark.rb
162
165
  - app/models/postman_mta/conversation.rb
@@ -164,6 +167,7 @@ files:
164
167
  - app/models/postman_mta/domain.rb
165
168
  - app/models/postman_mta/label.rb
166
169
  - app/models/postman_mta/message.rb
170
+ - app/models/postman_mta/note.rb
167
171
  - app/models/postman_mta/route.rb
168
172
  - app/models/postman_mta/tag.rb
169
173
  - bin/console
@@ -174,6 +178,7 @@ files:
174
178
  - lib/postman_mta/api_client.rb
175
179
  - lib/postman_mta/api_request.rb
176
180
  - lib/postman_mta/engine.rb
181
+ - lib/postman_mta/record_not_found.rb
177
182
  - lib/postman_mta/utils/sendfile_url.rb
178
183
  - lib/postman_mta/utils/signature.rb
179
184
  - lib/postman_mta/utils/signed_request.rb