keytechkit 0.3.17 → 0.3.18

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: 1b5c86101c08620c9f6217e628728f2a62f299a32a56944682d786c64d020d97
4
- data.tar.gz: 4ba5c80ee322c9bca3c9549637f54b9653df0c0e6eaf9d0499c9667c35015880
3
+ metadata.gz: 64f139c04206b65c49a5d884521669668fa0d3fa1e3d25a551951290727ca34a
4
+ data.tar.gz: 7f84363fa38b7df27c48a90293477ed318a2c70647e45a0efc14eea28fd31f93
5
5
  SHA512:
6
- metadata.gz: 9ac047cd7af2528d324b5176ab6ca681742904e01a4b53e862715f70bce001ac084014e62787ec31c221919515dfbff375792c96617a6e0ee39a162f2ac7c6a7
7
- data.tar.gz: 3d2c9ffcc8cfb6d5122a6b5f496f26c42d2383e980ed634fa4e0294d93db175d085fefb7f47e385936cfcce5d53838933219afc09c7b571de25e106c251bdba8
6
+ metadata.gz: 73262ac3bc1316c1842a12fa1b7328fd6319291d8816cc8bdd6fa31126c38f255bdb8bea2a17fa4d24fc8002eadb403bbbdff5a6a5f7502efe08a55915d5b2e0
7
+ data.tar.gz: 5f41d009fc94257bc50da5d4cc307892d397dfeb104b57c5472c1d96f4c58b3c1208bdf7b85635744664306441c4cf021fcad7138e892d4f2d618d91c8d37793
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- keytechkit (0.3.16)
4
+ keytechkit (0.3.18)
5
5
  httparty (~> 0.16)
6
6
 
7
7
  GEM
@@ -56,7 +56,8 @@ GEM
56
56
  erubi (1.7.1)
57
57
  globalid (0.4.1)
58
58
  activesupport (>= 4.2.0)
59
- httparty (0.16.2)
59
+ httparty (0.16.3)
60
+ mime-types (~> 3.0)
60
61
  multi_xml (>= 0.5.2)
61
62
  i18n (1.1.1)
62
63
  concurrent-ruby (~> 1.0)
@@ -68,6 +69,9 @@ GEM
68
69
  marcel (0.3.3)
69
70
  mimemagic (~> 0.3.2)
70
71
  method_source (0.9.1)
72
+ mime-types (3.2.2)
73
+ mime-types-data (~> 3.2015)
74
+ mime-types-data (3.2018.0812)
71
75
  mimemagic (0.3.2)
72
76
  mini_mime (1.0.1)
73
77
  mini_portile2 (2.3.0)
@@ -143,4 +147,4 @@ DEPENDENCIES
143
147
  rspec (~> 3.0)
144
148
 
145
149
  BUNDLED WITH
146
- 1.16.5
150
+ 1.17.1
@@ -9,23 +9,28 @@ module KeytechKit
9
9
  attr_accessor :createdBy
10
10
  attr_accessor :createdByLong
11
11
  attr_accessor :id
12
- attr_accessor :noteType
12
+ attr_accessor :note_type
13
13
  attr_accessor :subject
14
14
  attr_accessor :text
15
+ attr_accessor :element_key
15
16
 
16
17
  def initialize(data)
17
- self.changedAt = data['ChangedAt']
18
- self.changedBy = data['ChangedBy']
19
- self.changedByLong = data['ChangedByLong']
18
+ @changedAt = data['ChangedAt']
19
+ @changedBy = data['ChangedBy']
20
+ @changedByLong = data['ChangedByLong']
20
21
 
21
- self.createdAt = data['CreatedAt']
22
- self.createdBy = data['CreatedBy']
23
- self.createdByLong = data['CreatedByLong']
22
+ @createdAt = data['CreatedAt']
23
+ @createdBy = data['CreatedBy']
24
+ @createdByLong = data['CreatedByLong']
24
25
 
25
- self.id = data['ID']
26
- self.noteType = data['NoteType']
27
- self.subject = data['Subject']
28
- self.text = data['Text']
26
+ @id = data['ID'] || 0
27
+ @note_type = data['NoteType']
28
+ @subject = data['Subject']
29
+ @text = data['Text']
30
+ end
31
+
32
+ def to_hash
33
+ { NoteType: @note_type, Subject: @subject, Text: @text }
29
34
  end
30
35
  end
31
36
  end
@@ -1,5 +1,5 @@
1
1
  require 'keytechKit/elements/notes/note'
2
-
2
+ require 'keytechKit/elements/notes/note_type'
3
3
  module KeytechKit
4
4
  ##
5
5
  # Notes
@@ -12,23 +12,86 @@ module KeytechKit
12
12
  @auth = { username: username, password: password }
13
13
  end
14
14
 
15
- def load(elementKey)
15
+ def load(element_key)
16
16
  parameter = { basic_auth: @auth }
17
17
 
18
- response = self.class.get("/elements/#{elementKey}/notes", parameter)
18
+ response = self.class.get("/elements/#{element_key}/notes", parameter)
19
+ if response.success?
20
+ parse_notes(response['NotesList'], element_key)
21
+ else
22
+ # TODO: return an error object, dont raise exception
23
+ raise response.response
24
+ end
25
+ end
26
+
27
+ def load_note_types
28
+ parameter = { basic_auth: @auth }
29
+ response = self.class.get('/notetypes', parameter)
30
+ if response.success?
31
+ parse_note_types(response['Notetypes'])
32
+ else
33
+ # TODO: return an error object, dont raise exception
34
+ raise response.response
35
+ end
36
+ end
37
+
38
+ def create(note_type, element_key)
39
+ note = Note.new(NoteType: note_type)
40
+ note.note_type = note_type
41
+ note.element_key = element_key
42
+ note
43
+ end
44
+
45
+ def save(note)
46
+ element_key = note.element_key
47
+ note_hash = note.to_hash
48
+ parameter = { basic_auth: @auth,
49
+ body: note_hash.to_json,
50
+ headers: { 'Content-Type' => 'application/json; charset=utf-8
' } }
51
+
52
+ response = if note.id.zero?
53
+ self.class.post("/elements/#{element_key}/notes", parameter)
54
+ else
55
+ self.class.put("/elements/#{element_key}/notes", parameter)
56
+ end
19
57
  if response.success?
20
- parse_notes(response['NotesList'])
58
+ note.id = response.headers['location']
59
+ { id: response.headers['location'] }
21
60
  else
61
+ # TODO: return an error object, dont raise exception
22
62
  raise response.response
23
63
  end
24
64
  end
25
65
 
66
+ def remove(note)
67
+ parameter = { basic_auth: @auth }
68
+ element_key = note.element_key
69
+ note_id = note.id
70
+ response = self.class.delete("/elements/#{element_key}/notes/#{note_id}", parameter)
71
+ if response.success?
72
+ { success: true }
73
+ else
74
+ { success: false, error: response.headers['x-errordescription'].to_s }
75
+ end
76
+ end
77
+
26
78
  private
27
79
 
28
- def parse_notes(notesResult)
80
+ def parse_note_types(note_types_data)
81
+ note_types = []
82
+ note_types_data.each do |note_type_data|
83
+ note_type = NoteType.new(note_type_data)
84
+ note_types.push note_type
85
+ end
86
+ note_types
87
+ end
88
+
89
+ def parse_notes(notes_result, element_key)
29
90
  notes = []
30
- notesResult.each do |notedata|
31
- notes.push Note.new(notedata)
91
+ notes_result.each do |note_data|
92
+ note = Note.new(note_data)
93
+ note.element_key = element_key
94
+ notes.push note
32
95
  end
33
96
  notes
34
97
  end
@@ -0,0 +1,23 @@
1
+ module KeytechKit
2
+ ##
3
+ # A single note
4
+ class NoteType
5
+ attr_accessor :allow_modify
6
+ attr_accessor :displaytext
7
+ attr_accessor :id
8
+ attr_accessor :is_document_info
9
+ attr_accessor :is_folder_info
10
+ attr_accessor :is_masteritem_info
11
+ attr_accessor :is_system_info
12
+
13
+ def initialize(data)
14
+ @allow_modify = data['AllowModify']
15
+ @displaytext = data['Displaytext']
16
+ @id = data['ID']
17
+ @is_document_info = data['IsDocumentInfo']
18
+ @is_folder_info = data['IsFolderInfo']
19
+ @is_document_info = data['IsMasterItemInfo']
20
+ @is_system_info = data['IsSystemInfo']
21
+ end
22
+ end
23
+ end
@@ -1,5 +1,5 @@
1
1
  module KeytechKit
2
- VERSION = '0.3.17'
2
+ VERSION = '0.3.18'
3
3
 
4
4
  # Public available Demo URL for testing and dsevelopment
5
5
  DEMO_URL = 'https://demo.keytech.de'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: keytechkit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.17
4
+ version: 0.3.18
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thorsten Claus
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-11-13 00:00:00.000000000 Z
11
+ date: 2018-12-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -117,6 +117,7 @@ files:
117
117
  - lib/keytechKit/elements/group_by.rb
118
118
  - lib/keytechKit/elements/notes/note.rb
119
119
  - lib/keytechKit/elements/notes/note_handler.rb
120
+ - lib/keytechKit/elements/notes/note_type.rb
120
121
  - lib/keytechKit/elements/search_response_header.rb
121
122
  - lib/keytechKit/search.rb
122
123
  - lib/keytechKit/serverinfo.rb
@@ -146,7 +147,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
146
147
  version: '0'
147
148
  requirements: []
148
149
  rubyforge_project:
149
- rubygems_version: 2.7.7
150
+ rubygems_version: 2.7.8
150
151
  signing_key:
151
152
  specification_version: 4
152
153
  summary: keytechkit is a ruby gem to connect to the keytech Web API