setka-workflow 0.1.0 → 0.1.1
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 +4 -4
- data/CHANGELOG.md +9 -0
- data/lib/setka/workflow.rb +23 -0
- data/lib/setka/workflow/category.rb +34 -0
- data/lib/setka/workflow/resource.rb +4 -0
- data/lib/setka/workflow/ticket.rb +45 -0
- data/lib/setka/workflow/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 984c7eb517da01a15112df082649571809af9ba1
|
4
|
+
data.tar.gz: 9d37f010305da4fde4af901230b28c82b1eba04e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cbc377ec10c5a5babdf3c2d320875059f9254ce31761b7767a2dbf56884c4594674a07b60e10ba7e9c6938be622b42e3dffa3001d8c2b76327153230230745bb
|
7
|
+
data.tar.gz: ed243ad7a18de82380cfb0b53e6740f3c94a3ce034f905d21f790e5993d16555ca98d0cd6e0b31e4168536c0ce98c99fef523111e4369dc930bb23e4078455b7
|
data/CHANGELOG.md
ADDED
data/lib/setka/workflow.rb
CHANGED
@@ -1,5 +1,13 @@
|
|
1
1
|
require 'setka/workflow/version'
|
2
2
|
|
3
|
+
# Ruby implementations of Setka Workflow API for integration an external
|
4
|
+
# publishing platform written in the Ruby language with Setka Workflow.
|
5
|
+
#
|
6
|
+
# First of all access token should be obtained. It can be acomplished on
|
7
|
+
# Integration page of Settings
|
8
|
+
# (https://workflow.setka.io/spacename/settings/api
|
9
|
+
# where spacename is name of your space).
|
10
|
+
|
3
11
|
module Setka
|
4
12
|
module Workflow
|
5
13
|
autoload :Client, 'setka/workflow/client'
|
@@ -11,22 +19,36 @@ module Setka
|
|
11
19
|
autoload :Category, 'setka/workflow/category'
|
12
20
|
|
13
21
|
BASE_ENDPOINT = 'workflow.setka.io'.freeze
|
22
|
+
|
23
|
+
# Current default version of API
|
14
24
|
API_VERSION = 3
|
15
25
|
|
26
|
+
# Basic Workflow error
|
16
27
|
Error = Class.new(StandardError)
|
28
|
+
|
29
|
+
# This error is thrown when your client has not been configured
|
17
30
|
ConfigurationError = Class.new(Error)
|
31
|
+
|
32
|
+
# This error is thrown when format of the param is wrong
|
18
33
|
WrongParamError = Class.new(Error)
|
34
|
+
|
35
|
+
# This error is thrown when access token is invalid
|
19
36
|
InvalidAccessToken = Class.new(Error)
|
37
|
+
|
38
|
+
# This error is thrown when Setka Workflow responds with 500
|
20
39
|
InternalServerError = Class.new(Error)
|
21
40
|
|
41
|
+
# Clears current client
|
22
42
|
def self.reset!
|
23
43
|
@client = nil
|
24
44
|
end
|
25
45
|
|
46
|
+
# Gets current client
|
26
47
|
def self.client
|
27
48
|
@client ||= Setka::Workflow::Client.new
|
28
49
|
end
|
29
50
|
|
51
|
+
# Workflow client configuration in the global manner
|
30
52
|
def self.configure(&block)
|
31
53
|
reset!
|
32
54
|
client.configure(&block)
|
@@ -36,6 +58,7 @@ module Setka
|
|
36
58
|
@logger ||= Logger.new(STDOUT)
|
37
59
|
end
|
38
60
|
|
61
|
+
# Sets custom logger
|
39
62
|
def self.logger=(logger)
|
40
63
|
@logger = logger
|
41
64
|
end
|
@@ -1,15 +1,49 @@
|
|
1
1
|
module Setka
|
2
2
|
module Workflow
|
3
3
|
class Category < Resource
|
4
|
+
# Methods set to work with çategories
|
4
5
|
class << self
|
6
|
+
# Creates a category.
|
7
|
+
#
|
8
|
+
# @param [Hash] body Attributes of a new category.
|
9
|
+
#
|
10
|
+
# @param [Hash] options Additional options (explicit HTTP headers,
|
11
|
+
# specific Client object).
|
12
|
+
#
|
13
|
+
# @raise [Workflow::Category] If something went wrong during category's
|
14
|
+
# creation.
|
15
|
+
#
|
16
|
+
# @return [Hash] Hash of category's attibutes.
|
5
17
|
def create(body, options = {})
|
6
18
|
collection(:post, nil, body, options)
|
7
19
|
end
|
8
20
|
|
21
|
+
# Updates a category.
|
22
|
+
# @param [Integer] id Category's id
|
23
|
+
#
|
24
|
+
# @param [Hash] body Category's attributes to update.
|
25
|
+
#
|
26
|
+
# @param [Hash] options Additional options (explicit HTTP headers,
|
27
|
+
# specific Client object).
|
28
|
+
#
|
29
|
+
# @raise [Workflow::Category] If something went wrong during category's
|
30
|
+
# updating.
|
31
|
+
#
|
32
|
+
# @return [Hash] Hash of category's attibutes.
|
9
33
|
def update(id, body, options = {})
|
10
34
|
member(:patch, id, nil, body, options)
|
11
35
|
end
|
12
36
|
|
37
|
+
# Deletes a category.
|
38
|
+
# @param [Integer] id Category's id
|
39
|
+
#
|
40
|
+
# @param [Hash] options Additional options (explicit HTTP headers,
|
41
|
+
# specific Client object).
|
42
|
+
#
|
43
|
+
# @raise [Workflow::Category] If something went wrong during category's
|
44
|
+
# deleting.
|
45
|
+
#
|
46
|
+
# @return [Hash] Hash of category's attibutes.
|
13
47
|
def delete(id, options = {})
|
14
48
|
member(:delete, id, nil, nil, options)
|
15
49
|
end
|
@@ -2,10 +2,14 @@ module Setka
|
|
2
2
|
module Workflow
|
3
3
|
class Resource
|
4
4
|
class << self
|
5
|
+
# Abstract operation's execution over a member of a resource.
|
6
|
+
#
|
5
7
|
def member(http_verb, id, action = nil, body = nil, options)
|
6
8
|
actual_client(options).send(http_verb, path(action, id), body, options)
|
7
9
|
end
|
8
10
|
|
11
|
+
# Abstract operation's execution over a collection of a resource.
|
12
|
+
#
|
9
13
|
def collection(http_verb, action = nil, body = nil, options)
|
10
14
|
actual_client(options).send(http_verb, path(action), body, options)
|
11
15
|
end
|
@@ -1,19 +1,64 @@
|
|
1
1
|
module Setka
|
2
2
|
module Workflow
|
3
3
|
class Ticket < Resource
|
4
|
+
# Methods set to work with tickets
|
4
5
|
class << self
|
6
|
+
# Publishes a ticket.
|
7
|
+
#
|
8
|
+
# @param [Integer] id Ticket's id.
|
9
|
+
#
|
10
|
+
# @param [Hash] options Additional options (explicit HTTP headers,
|
11
|
+
# specific Client object).
|
12
|
+
#
|
13
|
+
# @raise [Workflow::Ticket] if a ticket with the given ID could not be found,
|
14
|
+
# if the ticket is already published.
|
15
|
+
#
|
16
|
+
# @return [Hash] Hash of ticket's attibutes.
|
5
17
|
def publish(id, options = {})
|
6
18
|
member(:patch, id, :publish, nil, options)
|
7
19
|
end
|
8
20
|
|
21
|
+
# Unpublishes a ticket.
|
22
|
+
#
|
23
|
+
# @param [Integer] id Ticket's id.
|
24
|
+
#
|
25
|
+
# @param [Hash] options Additional options (explicit HTTP headers,
|
26
|
+
# specific Client object).
|
27
|
+
#
|
28
|
+
# @raise [Workflow::Ticket] if a ticket with the given ID could not be found,
|
29
|
+
# if the ticket is already unpublished.
|
30
|
+
#
|
31
|
+
# @return [Hash] Hash of ticket's attibutes.
|
9
32
|
def unpublish(id, options = {})
|
10
33
|
member(:patch, id, :unpublish, nil, options)
|
11
34
|
end
|
12
35
|
|
36
|
+
# Updates a ticket.
|
37
|
+
#
|
38
|
+
# @param [Integer] id Ticket's id.
|
39
|
+
#
|
40
|
+
# @param [Hash] body Hash with ticket's attributes to update.
|
41
|
+
#
|
42
|
+
# @param [Hash] options Additional options (explicit HTTP headers,
|
43
|
+
# specific Client object).
|
44
|
+
#
|
45
|
+
# @raise [Workflow::Ticket] if a ticket with the given ID could not be found,
|
46
|
+
# if format of some attribute(s) is wrong (e.g. date and published_at
|
47
|
+
# should be passed as unix timestamps).
|
48
|
+
# @return [Hash] Hash of ticket's attibutes.
|
13
49
|
def update(id, body, options = {})
|
14
50
|
member(:patch, id, nil, body, options)
|
15
51
|
end
|
16
52
|
|
53
|
+
# Sync ticket's analytics.
|
54
|
+
#
|
55
|
+
# @param [Hash] body Hash with ticket's attributes to update.
|
56
|
+
#
|
57
|
+
# @param [Hash] options Additional options (explicit HTTP headers,
|
58
|
+
# specific Client object).
|
59
|
+
#
|
60
|
+
# @return [Array] Array of hashes with ticket's views and comment counts
|
61
|
+
# and the result of syncing.
|
17
62
|
def sync_analytics(body, options = {})
|
18
63
|
collection(:patch, :sync_analytics, body, options)
|
19
64
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: setka-workflow
|
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
|
- Dmitry Kovalevsky
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-09-
|
11
|
+
date: 2017-09-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -90,6 +90,7 @@ files:
|
|
90
90
|
- ".gitignore"
|
91
91
|
- ".rspec"
|
92
92
|
- ".travis.yml"
|
93
|
+
- CHANGELOG.md
|
93
94
|
- CODE_OF_CONDUCT.md
|
94
95
|
- Gemfile
|
95
96
|
- LICENSE.txt
|