swiftner 0.0.5 → 0.0.6

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: fcaad19a345368e1cd1c8660d53bcab7a8f5152c59221e335bf9c8057f17fbd1
4
- data.tar.gz: d1b40c55191e99e2326aac0850bc342f0eadde486f69c772a0fc828d9ad2c3e0
3
+ metadata.gz: 7fed0bd04566bcce81abf9cef775cd31ee2b4faf14709c190ea57a468804074e
4
+ data.tar.gz: 4d3c389378438555f00485e9f8cbee362a9d1757a8babbd5b545f5741f4f8b4c
5
5
  SHA512:
6
- metadata.gz: e847384adbdb29330517d383c310085b8fc34b3e47f9b4fddcba6d12c08dca276128eaa65e1fabc9d7149adeeeee5ac4ddf80ff9f5770a86862a190b3d37b2a3
7
- data.tar.gz: b74036ad768d3faa6c90d5564ef246153a01736785174cc2393410cb65559de4dbe41b35718313b85b27e50bcc81a3713c1f0f436cdf7f9730a9b3e8f1ac8726
6
+ metadata.gz: ec7c67f789d1f167cbde69b4a7a6df4d173a237500681bb2238525833312c86beed7198688d1a8dba9ed867155cbf468cdb32fb50d5d7b42c2d522ebe9ff818a
7
+ data.tar.gz: 0a3023b1c834c6791168659cb7a2bb0b0b6d4b7902070175c3e7423024a4010809fc74bb7aed2ae4c70e4cd782a28896131aa581bb3787ca780f655006aae8a7
data/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.0.6]
4
+ - Added Meeting service with CRUD operations and `start`, `end`, `pause` and `resume`. [#10](https://github.com/Swiftner/swiftner_ruby/pull/10)
5
+ - Added Channel service with CRUD operations and `live?`. [#9](https://github.com/Swiftner/swiftner_ruby/pull/9)
6
+ - Added Chapter service with CRUD operations. [#8](https://github.com/Swiftner/swiftner_ruby/pull/8)
7
+ - Added Organisation service with CRUD operations and `add_org_to_token`. [#7](https://github.com/Swiftner/swiftner_ruby/pull/7)
8
+
3
9
  ## [0.0.2] - 2024-02-13
4
10
 
5
11
  - Adds the first services supported.
data/RELEASING.md ADDED
@@ -0,0 +1,14 @@
1
+ # Releasing
2
+
3
+ 1. Update `lib/swiftner/version.rb` accordingly and run `bundle install` to update the Gemfile.lock.
4
+ 1. Update `CHANGELOG.md` to reflect the changes since last release. This means moving everyhing from the unrealesed section to an appropriate version section.
5
+ 1. Commit changes.
6
+ 1. Tag the release: `git tag -s vVERSION`
7
+ 1. Push changes: `git push && git push --tags`
8
+ 1. Build and publish:
9
+ ```bash
10
+ gem build swiftner.gemspe
11
+ gem push swiftner-VERSION.gem
12
+ ```
13
+ 1. Add a new GitHub release using the content from new version section of `CHANGELOG.md` as the content.
14
+ 1. Announce the new release, say "thank you" to the contributors.
@@ -0,0 +1,81 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Swiftner
4
+ module API
5
+ # Represents a Channel service responsible for finding, creating, updating and deleting channels.
6
+ # Inherits from the Service class.
7
+ # Provides methods for interacting with channel.
8
+ class Channel < Service
9
+ REQUIRED_ATTRIBUTES = %i[name type space_id].freeze
10
+
11
+ # Finds all channels
12
+ # @return [Array<Swiftner::API::Channel>]
13
+ def self.find_channels
14
+ response = client.get("/channel/get-channels")
15
+ map_collection(response)
16
+ end
17
+
18
+ # Finds channel by its id
19
+ # @param [Integer] channel_id
20
+ # @return [Swiftner::API::Channel]
21
+ def self.find(channel_id)
22
+ response = client.get("/channel/get/#{channel_id}")
23
+ build(response.parsed_response)
24
+ end
25
+
26
+ # @param [Hash] attributes
27
+ # @option attributes [String] :name (required)
28
+ # @option attributes [String] :type (required) - "audio", "video" or "dual"
29
+ # @option attributes [Integer] :space_id (required)
30
+ # @option attributes [String] :description (optional)
31
+ # @option attributes [Integer] :order (optional)
32
+ # @return [Swiftner::API::Channel]
33
+ def self.create(attributes)
34
+ validate_required(attributes, *REQUIRED_ATTRIBUTES)
35
+
36
+ response = client.post(
37
+ "/channel/create",
38
+ body: attributes.to_json,
39
+ headers: { "Content-Type" => "application/json" }
40
+ )
41
+
42
+ build(response.parsed_response)
43
+ end
44
+
45
+ # @return [Boolean]
46
+ def live?
47
+ client.get("/channel/is_channel_live?channel_id=#{id}")["status"] == "live"
48
+ rescue Swiftner::NotFound
49
+ # ?Why does api return 404 when channel is not live?
50
+ false
51
+ end
52
+
53
+ # @param [Hash] attributes
54
+ # @option attributes [String] :name (required)
55
+ # @option attributes [String] :type (required) - "audio", "video" or "dual"
56
+ # @option attributes [Integer] :space_id (required)
57
+ # @option attributes [String] :description (optional)
58
+ # @option attributes [Integer] :order (optional)
59
+ # @return [Swiftner::API::Channel]
60
+ def update(attributes)
61
+ attributes = attributes.transform_keys(&:to_s)
62
+ @details = @details.merge(attributes)
63
+
64
+ self.class.validate_required(@details, *REQUIRED_ATTRIBUTES)
65
+
66
+ client.put(
67
+ "/channel/update/#{id}",
68
+ body: @details.to_json,
69
+ headers: { "Content-Type" => "application/json" }
70
+ )
71
+ self
72
+ end
73
+
74
+ # Deletes channel by its id
75
+ # @return [Hash] response
76
+ def delete
77
+ client.delete("/channel/delete/#{id}")
78
+ end
79
+ end
80
+ end
81
+ end
@@ -0,0 +1,76 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Swiftner
4
+ module API
5
+ # Represents a chapter service responsible for finding, creating, and deleting chapters.
6
+ # Inherits from the Service class.
7
+ # Provides methods for interacting with chapters.
8
+ class Chapter < Service
9
+ REQUIRED_ATTRIBUTES = %i[title duration video_content_id start].freeze
10
+ # Finds all chapters for a video content.
11
+ # @param [Integer] video_content_id
12
+ # @return [Array<Swiftner::API::Chapter>]
13
+ def self.find_chapters(video_content_id)
14
+ response = client.get("/video-content/get/#{video_content_id}/chapters")
15
+ map_collection(response)
16
+ end
17
+
18
+ # Finds chapter by id.
19
+ # @param [Integer] chapter_id
20
+ # @return [Swiftner::API::Chapter]
21
+ def self.find(chapter_id)
22
+ response = client.get("/chapter/get/#{chapter_id}")
23
+ build(response.parsed_response)
24
+ end
25
+
26
+ # Creates a chapter.
27
+ # @param [Hash] attributes
28
+ # @option attributes [String] :title (required)
29
+ # @option attributes [String] :duration (required)
30
+ # @option attributes [Integer] :video_content_id (required)
31
+ # @option attributes [String] :start (required)
32
+ # @option attributes [String] :start_seconds (optional)
33
+ # @option attributes [String] :language (optional)
34
+ # @return [Swiftner::API::Chapter]
35
+ def self.create(attributes)
36
+ validate_required(attributes, *REQUIRED_ATTRIBUTES)
37
+
38
+ response = client.post(
39
+ "/chapter/create",
40
+ body: attributes.to_json,
41
+ headers: { "Content-Type" => "application/json" }
42
+ )
43
+
44
+ build(response.parsed_response)
45
+ end
46
+
47
+ # Creates a chapter.
48
+ # @param [Hash] attributes
49
+ # @option attributes [String] :title (optional)
50
+ # @option attributes [String] :duration (optional)
51
+ # @option attributes [Integer] :video_content_id (optional)
52
+ # @option attributes [String] :start (optional)
53
+ # @option attributes [String] :start_seconds (optional)
54
+ # @option attributes [String] :language (optional)
55
+ # @return [Swiftner::API::Chapter]
56
+ def update(attributes)
57
+ attributes = attributes.transform_keys(&:to_s)
58
+ @details = @details.merge(attributes)
59
+
60
+ self.class.validate_required(@details, *REQUIRED_ATTRIBUTES)
61
+
62
+ client.put(
63
+ "/chapter/update/#{id}",
64
+ body: @details.to_json,
65
+ headers: { "Content-Type" => "application/json" }
66
+ )
67
+ self
68
+ end
69
+
70
+ # @return [Hash]
71
+ def delete
72
+ client.delete("/chapter/delete/#{id}")
73
+ end
74
+ end
75
+ end
76
+ end
@@ -0,0 +1,127 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Swiftner
4
+ module API
5
+ # Represents a Meeting service responsible for finding, creating, and deleting spaces.
6
+ # Inherits from the Service class.
7
+ # Provides methods for interacting with meetings.
8
+ class Meeting < Service
9
+ REQUIRED_ATTRIBUTES = %i[space_id language].freeze
10
+ # Finds all meetings
11
+ # @return [Array<Swiftner::API::Meeting>]
12
+ def self.find_meetings
13
+ response = client.get("/meeting/get-meetings")
14
+ map_collection(response)
15
+ end
16
+
17
+ # Finds meeting by id
18
+ # @param [Integer] meeting_id
19
+ # @return [Swiftner::API::Meeting]
20
+ def self.find(meeting_id)
21
+ response = client.get("/meeting/get/#{meeting_id}")
22
+ build(response.parsed_response)
23
+ end
24
+
25
+ # Creates a meeting.
26
+ # @param [Hash] attributes
27
+ # @option attributes [Integer] :space_id (required)
28
+ # @option attributes [String] :language (required)
29
+ # @option attributes [String] :title (optional)
30
+ # @option attributes [String] :description (optional)
31
+ # @option attributes [String] :start (optional) eg. "2024-09-06T08:37:45.162Z"
32
+ # @option attributes [Integer] :duration (optional)
33
+ # @option attributes [String] :thumbnail_url (optional)
34
+ # @option attributes [String] :state (optional) eg. "not_started", "ended"
35
+ # @option attributes [Integer] :prompt_id (optional)
36
+ # @return [Swiftner::API::Meeting]
37
+ def self.create(attributes)
38
+ validate_required(attributes, *REQUIRED_ATTRIBUTES)
39
+
40
+ response = client.post(
41
+ "/meeting/create",
42
+ body: attributes.to_json,
43
+ headers: { "Content-Type" => "application/json" }
44
+ )
45
+
46
+ build(response.parsed_response)
47
+ end
48
+
49
+ # Starts a meeting
50
+ # @return [Swiftner::API::Meeting]
51
+ def start
52
+ response = client.post(
53
+ "/meeting/#{id}/start",
54
+ headers: { "Content-Type" => "application/json" }
55
+ )
56
+
57
+ @details = response
58
+ self
59
+ end
60
+
61
+ # Ends a meeting
62
+ # @return [Swiftner::API::Meeting]
63
+ def end
64
+ response = client.post(
65
+ "/meeting/#{id}/end",
66
+ headers: { "Content-Type" => "application/json" }
67
+ )
68
+ @details = response.parsed_response
69
+ self
70
+ end
71
+
72
+ # Pauses a meeting
73
+ # @return [Swiftner::API::Meeting, nil]
74
+ def pause
75
+ response = client.post(
76
+ "/meeting/#{id}/pause",
77
+ headers: { "Content-Type" => "application/json" }
78
+ )
79
+ @details = response.parsed_response
80
+ self
81
+ end
82
+
83
+ # Resumes a meeting
84
+ # @return [Swiftner::API::Meeting]
85
+ def resume
86
+ response = client.post(
87
+ "/meeting/#{id}/resume",
88
+ headers: { "Content-Type" => "application/json" }
89
+ )
90
+ @details = response.parsed_response
91
+ self
92
+ end
93
+
94
+ # Updates a meeting.
95
+ # @param [Hash] attributes
96
+ # @option attributes [Integer] :space_id (optional)
97
+ # @option attributes [String] :language (optional) eg. "no", "en"
98
+ # @option attributes [String] :title (optional)
99
+ # @option attributes [String] :description (optional)
100
+ # @option attributes [String] :start (optional) eg. "2024-09-06T08:37:45.162Z"
101
+ # @option attributes [Integer] :duration (optional)
102
+ # @option attributes [String] :thumbnail_url (optional)
103
+ # @option attributes [String] :state (optional) eg. "not_started", "ended"
104
+ # @option attributes [Integer] :prompt_id (optional)
105
+ # @return [Swiftner::API::Meeting]
106
+ def update(attributes)
107
+ attributes = attributes.transform_keys(&:to_s)
108
+ @details = @details.merge(attributes)
109
+
110
+ self.class.validate_required(@details, :language, :space)
111
+
112
+ client.put(
113
+ "/meeting/update/#{id}",
114
+ body: @details.to_json,
115
+ headers: { "Content-Type" => "application/json" }
116
+ )
117
+ self
118
+ end
119
+
120
+ # Deletes a meeting.
121
+ # @return [Hash]
122
+ def delete
123
+ client.delete("/meeting/delete/#{id}")
124
+ end
125
+ end
126
+ end
127
+ end
@@ -0,0 +1,77 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Swiftner
4
+ module API
5
+ # Represents a Organisation service responsible for finding, creating, and deleting organisations.
6
+ # Inherits from the Service class.
7
+ # Provides methods for interacting with spaces.
8
+ class Organisation < Service
9
+ REQUIRED_ATTRIBUTES = %i[name].freeze
10
+
11
+ # Finds all organisations user is in
12
+ # @return [Array<Swiftner::API::Organisation>]
13
+ def self.find_organisations
14
+ response = client.get("/organisation/get-current-user-orgs")
15
+ map_collection(response)
16
+ end
17
+
18
+ # Finds organisation by id
19
+ # @param [Integer] organisation_id
20
+ # @return [Swiftner::API::Organisation]
21
+ def self.find(organisation_id)
22
+ response = client.get("/organisation/get/#{organisation_id}")
23
+ build(response.parsed_response)
24
+ end
25
+
26
+ # Add org to token
27
+ # @param [Integer] organisation_id
28
+ # @return [Hash] {access_hash: String, refresh_token: String}
29
+ def self.add_org_to_token(organisation_id)
30
+ client.put("/organisation/add-org-to-token?organisation_id=#{organisation_id}")
31
+ end
32
+
33
+ # Creates a new organisation
34
+ # @param [Hash] attributes
35
+ # @option attributes [String] :name (required)
36
+ # @option attributes [String] :description (optional)
37
+ # @option attributes [Integer] :default_prompt_id (optional)
38
+ # @option attributes [String] :language (optional)
39
+ # @return [Swiftner::API::Organisation]
40
+ def self.create(attributes)
41
+ validate_required(attributes, *REQUIRED_ATTRIBUTES)
42
+ response = client.post(
43
+ "/organisation/create",
44
+ body: attributes.to_json,
45
+ headers: { "Content-Type" => "application/json" }
46
+ )
47
+ build(response.parsed_response)
48
+ end
49
+
50
+ # Updates organisation
51
+ # @param [Hash] attributes
52
+ # @option attributes [String] :name (optional)
53
+ # @option attributes [String] :description (optional)
54
+ # @option attributes [Integer] :default_prompt_id (optional)
55
+ # @option attributes [String] :language (optional)
56
+ # @return [Swiftner::API::Organisation]
57
+ def update(attributes)
58
+ attributes = attributes.transform_keys(&:to_s)
59
+ @details = @details.merge(attributes)
60
+
61
+ self.class.validate_required(@details, *REQUIRED_ATTRIBUTES)
62
+
63
+ client.put(
64
+ "/organisation/update/#{id}",
65
+ body: @details.to_json,
66
+ headers: { "Content-Type" => "application/json" }
67
+ )
68
+ self
69
+ end
70
+
71
+ # Deletes organisation
72
+ def delete
73
+ client.delete("/organisation/delete/#{id}")
74
+ end
75
+ end
76
+ end
77
+ end
@@ -29,7 +29,7 @@ module Swiftner
29
29
 
30
30
  def handle_response(response)
31
31
  case response.code
32
- when 200 then response
32
+ when 200, 201 then response
33
33
  when 401 then raise Unauthorized.from_response(response)
34
34
  when 403 then raise Forbidden.from_response(response)
35
35
  when 404 then raise NotFound.from_response(response)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Swiftner
4
- VERSION = "0.0.5"
4
+ VERSION = "0.0.6"
5
5
  end
data/lib/swiftner.rb CHANGED
@@ -7,6 +7,10 @@ require_relative "swiftner/API/transcription"
7
7
  require_relative "swiftner/API/upload"
8
8
  require_relative "swiftner/API/video_content"
9
9
  require_relative "swiftner/API/linked_content"
10
+ require_relative "swiftner/API/channel"
11
+ require_relative "swiftner/API/chapter"
12
+ require_relative "swiftner/API/organisation"
13
+ require_relative "swiftner/API/meeting"
10
14
  require_relative "swiftner/configuration"
11
15
  require_relative "swiftner/client"
12
16
  require_relative "swiftner/version"
data/swiftner.gemspec ADDED
@@ -0,0 +1,40 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "lib/swiftner/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "swiftner"
7
+ spec.version = Swiftner::VERSION
8
+ spec.authors = ["Martin Ulleberg"]
9
+ spec.email = ["martin.ulleberg@gmail.com"]
10
+
11
+ spec.summary = "API wrapper for Swiftner's AI transcription service."
12
+ spec.description = "This gem provides an easy-to-use interface for Swiftner's API, allowing seamless integration of\
13
+ AI-driven transcription services into your Ruby applications."
14
+ spec.homepage = "https://swiftner.com"
15
+ spec.required_ruby_version = ">= 3.0.0"
16
+
17
+ spec.metadata["homepage_uri"] = spec.homepage
18
+ spec.metadata["source_code_uri"] = "https://github.com/swiftner/swiftner_ruby"
19
+ spec.metadata["changelog_uri"] = "https://github.com/swiftner/swiftner_ruby/blob/main/CHANGELOG.md"
20
+
21
+ # Specify which files should be added to the gem when it is released.
22
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
23
+ spec.files = Dir.chdir(__dir__) do
24
+ `git ls-files -z`.split("\x0").reject do |f|
25
+ (File.expand_path(f) == __FILE__) ||
26
+ f.start_with?(*%w[bin/ test/ spec/ features/ .git .github appveyor Gemfile])
27
+ end
28
+ end
29
+ spec.bindir = "exe"
30
+ spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
31
+ spec.require_paths = ["lib"]
32
+
33
+ spec.add_dependency "httparty", "~> 0.21"
34
+ # Uncomment to register a new dependency of your gem
35
+ # spec.add_dependency "example-gem", "~> 1.0"
36
+
37
+ # For more information and examples about making a new gem, check out our
38
+ # guide at: https://bundler.io/guides/creating_gem.html
39
+ spec.metadata["rubygems_mfa_required"] = "true"
40
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: swiftner
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Martin Ulleberg
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-03-07 00:00:00.000000000 Z
11
+ date: 2024-09-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty
@@ -36,9 +36,14 @@ files:
36
36
  - CHANGELOG.md
37
37
  - CODE_OF_CONDUCT.md
38
38
  - README.md
39
+ - RELEASING.md
39
40
  - Rakefile
40
41
  - lib/swiftner.rb
42
+ - lib/swiftner/API/channel.rb
43
+ - lib/swiftner/API/chapter.rb
41
44
  - lib/swiftner/API/linked_content.rb
45
+ - lib/swiftner/API/meeting.rb
46
+ - lib/swiftner/API/organisation.rb
42
47
  - lib/swiftner/API/service.rb
43
48
  - lib/swiftner/API/space.rb
44
49
  - lib/swiftner/API/transcription.rb
@@ -48,6 +53,7 @@ files:
48
53
  - lib/swiftner/configuration.rb
49
54
  - lib/swiftner/error.rb
50
55
  - lib/swiftner/version.rb
56
+ - swiftner.gemspec
51
57
  homepage: https://swiftner.com
52
58
  licenses: []
53
59
  metadata:
@@ -70,7 +76,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
70
76
  - !ruby/object:Gem::Version
71
77
  version: '0'
72
78
  requirements: []
73
- rubygems_version: 3.5.5
79
+ rubygems_version: 3.5.3
74
80
  signing_key:
75
81
  specification_version: 4
76
82
  summary: API wrapper for Swiftner's AI transcription service.