magloft 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/README.md +25 -0
- data/lib/magloft.rb +60 -0
- data/lib/magloft/model/base.rb +38 -0
- data/lib/magloft/model/issue.rb +25 -0
- data/lib/magloft/model/publication.rb +7 -0
- data/lib/magloft/model/typeloft_page.rb +7 -0
- data/lib/magloft/model/typeloft_theme.rb +7 -0
- data/lib/magloft/model/user.rb +7 -0
- data/lib/magloft/version.rb +3 -0
- metadata +135 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: e29215cf437166111ab5967862b5db668f14130f
|
4
|
+
data.tar.gz: fb87181d7ac5c76f37a8075135849b74585b1a05
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: ab0f2e603f274a01311849ff07172e3996dbb2a898431efcfd2459bc2e6658eaba65330829720edac0fa9eb1001e5121df266487f261e936c773cfd9ae6d4a5a
|
7
|
+
data.tar.gz: 024ad4a92d02b2b3129e3e04747ebada021260789a1cc126050b2e6bbc3f32cd889960c4995558d785a063cb38a66371cd2c30146989d619977f753d7ee3567c
|
data/README.md
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# magloft
|
2
|
+
|
3
|
+
> magloft allows you to connect your system to the MagLoft API
|
4
|
+
|
5
|
+
## Description
|
6
|
+
|
7
|
+
@TODO
|
8
|
+
|
9
|
+
## Installation
|
10
|
+
|
11
|
+
Install globally using `gem install magloft` or include it in your project Gemfile:
|
12
|
+
|
13
|
+
```ruby
|
14
|
+
source 'http://rubygems.org'
|
15
|
+
|
16
|
+
gem 'magloft'
|
17
|
+
```
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
@TODO
|
22
|
+
|
23
|
+
## License
|
24
|
+
|
25
|
+
magloft is available under an MIT-style license.
|
data/lib/magloft.rb
ADDED
@@ -0,0 +1,60 @@
|
|
1
|
+
require "her"
|
2
|
+
|
3
|
+
class AccessTokenAuthentication < Faraday::Middleware
|
4
|
+
def call(env)
|
5
|
+
env[:request_headers]["X-Magloft-Accesstoken"] = Magloft.access_token
|
6
|
+
@app.call(env)
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
module Magloft
|
11
|
+
API = Her::API.new
|
12
|
+
API.setup url: ENV['MAGLOFT_API_URL'] || "https://www.magloft.com" do |c|
|
13
|
+
c.use AccessTokenAuthentication
|
14
|
+
c.use Faraday::Request::UrlEncoded
|
15
|
+
c.use Her::Middleware::DefaultParseJSON
|
16
|
+
c.use Faraday::Adapter::NetHttp
|
17
|
+
end
|
18
|
+
|
19
|
+
@@app_id = nil
|
20
|
+
def self.app_id
|
21
|
+
@@app_id
|
22
|
+
end
|
23
|
+
|
24
|
+
@@access_token = nil
|
25
|
+
def self.access_token
|
26
|
+
@@access_token
|
27
|
+
end
|
28
|
+
|
29
|
+
def self.auth(access_token, app_id)
|
30
|
+
@@access_token = access_token
|
31
|
+
@@app_id = app_id
|
32
|
+
end
|
33
|
+
|
34
|
+
def self.users
|
35
|
+
Model::User
|
36
|
+
end
|
37
|
+
|
38
|
+
def self.publications
|
39
|
+
Model::Publication
|
40
|
+
end
|
41
|
+
|
42
|
+
def self.issues
|
43
|
+
Model::Issue
|
44
|
+
end
|
45
|
+
|
46
|
+
def self.typeloft_themes
|
47
|
+
Model::TypeloftTheme
|
48
|
+
end
|
49
|
+
|
50
|
+
def self.typeloft_pages
|
51
|
+
Model::TypeloftPage
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
require "magloft/model/base"
|
56
|
+
require "magloft/model/publication"
|
57
|
+
require "magloft/model/user"
|
58
|
+
require "magloft/model/issue"
|
59
|
+
require "magloft/model/typeloft_theme"
|
60
|
+
require "magloft/model/typeloft_page"
|
@@ -0,0 +1,38 @@
|
|
1
|
+
module Magloft
|
2
|
+
module Model
|
3
|
+
class Base
|
4
|
+
include Her::Model
|
5
|
+
use_api Magloft::API
|
6
|
+
|
7
|
+
def self.build_request_path(path = nil, parameters = {})
|
8
|
+
parameters = parameters.try(:with_indifferent_access)
|
9
|
+
|
10
|
+
unless path.kind_of?(String)
|
11
|
+
parameters = path.try(:with_indifferent_access) || parameters
|
12
|
+
path =
|
13
|
+
if parameters.include?(primary_key) && parameters[primary_key] && !parameters[primary_key].kind_of?(Array)
|
14
|
+
resource_path.dup
|
15
|
+
else
|
16
|
+
collection_path.dup
|
17
|
+
end
|
18
|
+
|
19
|
+
# Replace :id with our actual primary key
|
20
|
+
path.gsub!(%r{(\A|/):id(\Z|/)}, "\\1:#{primary_key}\\2")
|
21
|
+
end
|
22
|
+
|
23
|
+
path.gsub(/:([\w_]+)/) do
|
24
|
+
# Look for :key or :_key, otherwise raise an exception
|
25
|
+
key = $1.to_sym
|
26
|
+
value = parameters.delete(key) || parameters.delete(:"_#{key}")
|
27
|
+
if value
|
28
|
+
Faraday::Utils.escape value
|
29
|
+
elsif $1 == "app_id"
|
30
|
+
Magloft.app_id
|
31
|
+
else
|
32
|
+
raise(Her::Errors::PathError.new("Missing :_#{$1} parameter to build the request path. Path is `#{path}`. Parameters are `#{parameters.symbolize_keys.inspect}`.", $1))
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module Magloft
|
2
|
+
module Model
|
3
|
+
class Issue < Base
|
4
|
+
collection_path "api/portal/v1/issues/:app_id"
|
5
|
+
def process_links
|
6
|
+
url = self.class.build_request_path("#{self.class.collection_path}/:id/process_links", id: id)
|
7
|
+
self.class.put_raw(url)
|
8
|
+
true
|
9
|
+
end
|
10
|
+
|
11
|
+
def typeloft_pages
|
12
|
+
TypeloftPage.where(issue_id: id)
|
13
|
+
end
|
14
|
+
|
15
|
+
def build_page(design_identifier, options = {})
|
16
|
+
TypeloftPage.build({
|
17
|
+
position: 0,
|
18
|
+
design_identifier: design_identifier,
|
19
|
+
template_identifier: "blank",
|
20
|
+
issue_id: id
|
21
|
+
}.merge(options))
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
metadata
ADDED
@@ -0,0 +1,135 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: magloft
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Tobias Strebitzer
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-02-28 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: activesupport
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '4.0'
|
20
|
+
- - "<"
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '6.0'
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '4.0'
|
30
|
+
- - "<"
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '6.0'
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: bundler
|
35
|
+
requirement: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - ">="
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: 1.3.0
|
40
|
+
- - "<"
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: '2.0'
|
43
|
+
type: :runtime
|
44
|
+
prerelease: false
|
45
|
+
version_requirements: !ruby/object:Gem::Requirement
|
46
|
+
requirements:
|
47
|
+
- - ">="
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: 1.3.0
|
50
|
+
- - "<"
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: '2.0'
|
53
|
+
- !ruby/object:Gem::Dependency
|
54
|
+
name: her
|
55
|
+
requirement: !ruby/object:Gem::Requirement
|
56
|
+
requirements:
|
57
|
+
- - "~>"
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
version: '0.10'
|
60
|
+
type: :runtime
|
61
|
+
prerelease: false
|
62
|
+
version_requirements: !ruby/object:Gem::Requirement
|
63
|
+
requirements:
|
64
|
+
- - "~>"
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
version: '0.10'
|
67
|
+
- !ruby/object:Gem::Dependency
|
68
|
+
name: pry
|
69
|
+
requirement: !ruby/object:Gem::Requirement
|
70
|
+
requirements:
|
71
|
+
- - "~>"
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
version: '0.11'
|
74
|
+
type: :development
|
75
|
+
prerelease: false
|
76
|
+
version_requirements: !ruby/object:Gem::Requirement
|
77
|
+
requirements:
|
78
|
+
- - "~>"
|
79
|
+
- !ruby/object:Gem::Version
|
80
|
+
version: '0.11'
|
81
|
+
- !ruby/object:Gem::Dependency
|
82
|
+
name: rubocop
|
83
|
+
requirement: !ruby/object:Gem::Requirement
|
84
|
+
requirements:
|
85
|
+
- - "~>"
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
version: 0.52.1
|
88
|
+
type: :development
|
89
|
+
prerelease: false
|
90
|
+
version_requirements: !ruby/object:Gem::Requirement
|
91
|
+
requirements:
|
92
|
+
- - "~>"
|
93
|
+
- !ruby/object:Gem::Version
|
94
|
+
version: 0.52.1
|
95
|
+
description: magloft allows you to connect your system to the MagLoft API
|
96
|
+
email:
|
97
|
+
- tobias.strebitzer@magloft.com
|
98
|
+
executables: []
|
99
|
+
extensions: []
|
100
|
+
extra_rdoc_files: []
|
101
|
+
files:
|
102
|
+
- README.md
|
103
|
+
- lib/magloft.rb
|
104
|
+
- lib/magloft/model/base.rb
|
105
|
+
- lib/magloft/model/issue.rb
|
106
|
+
- lib/magloft/model/publication.rb
|
107
|
+
- lib/magloft/model/typeloft_page.rb
|
108
|
+
- lib/magloft/model/typeloft_theme.rb
|
109
|
+
- lib/magloft/model/user.rb
|
110
|
+
- lib/magloft/version.rb
|
111
|
+
homepage: https://github.com/magloft/magloft-ruby
|
112
|
+
licenses:
|
113
|
+
- BSD-3-Clause
|
114
|
+
metadata: {}
|
115
|
+
post_install_message:
|
116
|
+
rdoc_options: []
|
117
|
+
require_paths:
|
118
|
+
- lib
|
119
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
120
|
+
requirements:
|
121
|
+
- - "~>"
|
122
|
+
- !ruby/object:Gem::Version
|
123
|
+
version: '2.3'
|
124
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
125
|
+
requirements:
|
126
|
+
- - "~>"
|
127
|
+
- !ruby/object:Gem::Version
|
128
|
+
version: '2.4'
|
129
|
+
requirements: []
|
130
|
+
rubyforge_project:
|
131
|
+
rubygems_version: 2.6.10
|
132
|
+
signing_key:
|
133
|
+
specification_version: 4
|
134
|
+
summary: MagLoft API Client
|
135
|
+
test_files: []
|