forem-ruby 0.1.0.beta1
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 +7 -0
- data/LICENSE +21 -0
- data/forem-ruby.gemspec +17 -0
- data/lib/forem/api_operations/create.rb +47 -0
- data/lib/forem/api_operations/delete.rb +88 -0
- data/lib/forem/api_operations/list.rb +70 -0
- data/lib/forem/api_operations/request.rb +83 -0
- data/lib/forem/api_operations/retrieve.rb +43 -0
- data/lib/forem/api_operations/save.rb +53 -0
- data/lib/forem/api_operations/update.rb +47 -0
- data/lib/forem/api_requestor.rb +283 -0
- data/lib/forem/api_resource.rb +77 -0
- data/lib/forem/client.rb +279 -0
- data/lib/forem/configuration.rb +74 -0
- data/lib/forem/connection_manager.rb +75 -0
- data/lib/forem/errors.rb +118 -0
- data/lib/forem/forem_object.rb +264 -0
- data/lib/forem/forem_response.rb +50 -0
- data/lib/forem/list_object.rb +171 -0
- data/lib/forem/resources/admin_concept.rb +169 -0
- data/lib/forem/resources/admin_user.rb +152 -0
- data/lib/forem/resources/agent_session.rb +110 -0
- data/lib/forem/resources/analytics.rb +151 -0
- data/lib/forem/resources/article.rb +256 -0
- data/lib/forem/resources/billboard.rb +76 -0
- data/lib/forem/resources/comment.rb +43 -0
- data/lib/forem/resources/concept.rb +192 -0
- data/lib/forem/resources/follow.rb +78 -0
- data/lib/forem/resources/follower.rb +56 -0
- data/lib/forem/resources/health_check.rb +70 -0
- data/lib/forem/resources/organization.rb +79 -0
- data/lib/forem/resources/page.rb +52 -0
- data/lib/forem/resources/podcast_episode.rb +36 -0
- data/lib/forem/resources/profile_image.rb +44 -0
- data/lib/forem/resources/reaction.rb +61 -0
- data/lib/forem/resources/reading_list.rb +29 -0
- data/lib/forem/resources/recommended_articles_list.rb +45 -0
- data/lib/forem/resources/request_redirect.rb +60 -0
- data/lib/forem/resources/segment.rb +103 -0
- data/lib/forem/resources/survey.rb +96 -0
- data/lib/forem/resources/tag.rb +27 -0
- data/lib/forem/resources/trend.rb +80 -0
- data/lib/forem/resources/user.rb +229 -0
- data/lib/forem/resources/video.rb +28 -0
- data/lib/forem/services/admin_concept_service.rb +138 -0
- data/lib/forem/services/admin_user_service.rb +114 -0
- data/lib/forem/services/agent_session_service.rb +87 -0
- data/lib/forem/services/analytics_service.rb +93 -0
- data/lib/forem/services/article_service.rb +233 -0
- data/lib/forem/services/base_service.rb +45 -0
- data/lib/forem/services/billboard_service.rb +91 -0
- data/lib/forem/services/comment_service.rb +51 -0
- data/lib/forem/services/concept_service.rb +143 -0
- data/lib/forem/services/follow_service.rb +61 -0
- data/lib/forem/services/follower_service.rb +34 -0
- data/lib/forem/services/health_check_service.rb +46 -0
- data/lib/forem/services/organization_service.rb +103 -0
- data/lib/forem/services/page_service.rb +107 -0
- data/lib/forem/services/podcast_episode_service.rb +34 -0
- data/lib/forem/services/profile_image_service.rb +32 -0
- data/lib/forem/services/reaction_service.rb +72 -0
- data/lib/forem/services/reading_list_service.rb +35 -0
- data/lib/forem/services/recommended_articles_list_service.rb +87 -0
- data/lib/forem/services/request_redirect_service.rb +118 -0
- data/lib/forem/services/segment_service.rb +83 -0
- data/lib/forem/services/survey_service.rb +48 -0
- data/lib/forem/services/tag_service.rb +32 -0
- data/lib/forem/services/trend_service.rb +70 -0
- data/lib/forem/services/user_service.rb +61 -0
- data/lib/forem/services/video_service.rb +33 -0
- data/lib/forem/util.rb +43 -0
- data/lib/forem/version.rb +4 -0
- data/lib/forem.rb +91 -0
- metadata +111 -0
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
module Forem
|
|
2
|
+
module Services
|
|
3
|
+
# Service for interacting with the Forem Videos API.
|
|
4
|
+
#
|
|
5
|
+
# Lists articles that contain video content.
|
|
6
|
+
# Access via {Client#videos}. All methods inject the client's requestor
|
|
7
|
+
# automatically so no additional configuration is required.
|
|
8
|
+
#
|
|
9
|
+
# @example
|
|
10
|
+
# client = Forem::Client.new("your-api-key")
|
|
11
|
+
# videos = client.videos.list(page: 1)
|
|
12
|
+
#
|
|
13
|
+
# @see Video
|
|
14
|
+
# @see https://developers.forem.com/api/v1#/operations/videos
|
|
15
|
+
class VideoService < BaseService
|
|
16
|
+
# List articles that contain videos.
|
|
17
|
+
#
|
|
18
|
+
# @param params [Hash] query parameters
|
|
19
|
+
# @option params [Integer] :page page number (default: 1)
|
|
20
|
+
# @option params [Integer] :per_page number of results per page
|
|
21
|
+
# @param opts [Hash] per-request options
|
|
22
|
+
# @return [Array<Video>] list of articles with video content
|
|
23
|
+
#
|
|
24
|
+
# @example
|
|
25
|
+
# client.videos.list(page: 2)
|
|
26
|
+
#
|
|
27
|
+
# @see https://developers.forem.com/api/v1#/operations/videos
|
|
28
|
+
def list(params = {}, opts = {})
|
|
29
|
+
Video.list(params, opts_with_requestor(opts))
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
data/lib/forem/util.rb
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
module Forem
|
|
2
|
+
# Utility helpers used internally by the forem-ruby library.
|
|
3
|
+
#
|
|
4
|
+
# These methods are not part of the public API surface for end users but are
|
|
5
|
+
# documented here for contributors and library maintainers.
|
|
6
|
+
module Util
|
|
7
|
+
# Recursively convert a raw Ruby value into the appropriate Forem type.
|
|
8
|
+
#
|
|
9
|
+
# The conversion rules are:
|
|
10
|
+
# * +Hash+ → {ForemObject} (via {ForemObject.construct_from})
|
|
11
|
+
# * +Array+ → Array with each element passed through this method
|
|
12
|
+
# * anything else → returned unchanged
|
|
13
|
+
#
|
|
14
|
+
# This method is called during attribute assignment in {ForemObject} so
|
|
15
|
+
# that nested API response hashes automatically become {ForemObject}
|
|
16
|
+
# instances with dynamic attribute access.
|
|
17
|
+
#
|
|
18
|
+
# @param value [Object] the raw value to convert.
|
|
19
|
+
# @return [ForemObject, Array, Object] the converted value.
|
|
20
|
+
#
|
|
21
|
+
# @example Converting a hash
|
|
22
|
+
# Forem::Util.convert_to_forem_object({ "id" => 1, "name" => "Alice" })
|
|
23
|
+
# #=> #<Forem::ForemObject ...>
|
|
24
|
+
#
|
|
25
|
+
# @example Converting an array of hashes
|
|
26
|
+
# Forem::Util.convert_to_forem_object([{ "id" => 1 }, { "id" => 2 }])
|
|
27
|
+
# #=> [#<Forem::ForemObject ...>, #<Forem::ForemObject ...>]
|
|
28
|
+
#
|
|
29
|
+
# @example Passing through a scalar value
|
|
30
|
+
# Forem::Util.convert_to_forem_object("hello") #=> "hello"
|
|
31
|
+
# Forem::Util.convert_to_forem_object(42) #=> 42
|
|
32
|
+
def self.convert_to_forem_object(value)
|
|
33
|
+
case value
|
|
34
|
+
when Hash
|
|
35
|
+
ForemObject.construct_from(value)
|
|
36
|
+
when Array
|
|
37
|
+
value.map { |v| convert_to_forem_object(v) }
|
|
38
|
+
else
|
|
39
|
+
value
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
end
|
data/lib/forem.rb
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
require "forem/version"
|
|
2
|
+
require "forem/configuration"
|
|
3
|
+
require "forem/errors"
|
|
4
|
+
require "forem/forem_response"
|
|
5
|
+
require "forem/connection_manager"
|
|
6
|
+
require "forem/util"
|
|
7
|
+
require "forem/api_operations/request"
|
|
8
|
+
require "forem/list_object"
|
|
9
|
+
require "forem/forem_object"
|
|
10
|
+
require "forem/api_operations/retrieve"
|
|
11
|
+
require "forem/api_operations/create"
|
|
12
|
+
require "forem/api_operations/update"
|
|
13
|
+
require "forem/api_operations/delete"
|
|
14
|
+
require "forem/api_operations/list"
|
|
15
|
+
require "forem/api_operations/save"
|
|
16
|
+
require "forem/api_resource"
|
|
17
|
+
require "forem/api_requestor"
|
|
18
|
+
require "forem/resources/article"
|
|
19
|
+
require "forem/resources/user"
|
|
20
|
+
require "forem/resources/comment"
|
|
21
|
+
require "forem/resources/organization"
|
|
22
|
+
require "forem/resources/tag"
|
|
23
|
+
require "forem/resources/follow"
|
|
24
|
+
require "forem/resources/follower"
|
|
25
|
+
require "forem/resources/reading_list"
|
|
26
|
+
require "forem/resources/podcast_episode"
|
|
27
|
+
require "forem/resources/video"
|
|
28
|
+
require "forem/resources/profile_image"
|
|
29
|
+
require "forem/resources/billboard"
|
|
30
|
+
require "forem/resources/page"
|
|
31
|
+
require "forem/resources/segment"
|
|
32
|
+
require "forem/resources/reaction"
|
|
33
|
+
require "forem/resources/recommended_articles_list"
|
|
34
|
+
require "forem/resources/agent_session"
|
|
35
|
+
require "forem/resources/survey"
|
|
36
|
+
require "forem/resources/analytics"
|
|
37
|
+
require "forem/resources/health_check"
|
|
38
|
+
require "forem/resources/admin_user"
|
|
39
|
+
require "forem/resources/trend"
|
|
40
|
+
require "forem/resources/concept"
|
|
41
|
+
require "forem/resources/admin_concept"
|
|
42
|
+
require "forem/resources/request_redirect"
|
|
43
|
+
require "forem/services/base_service"
|
|
44
|
+
require "forem/services/article_service"
|
|
45
|
+
require "forem/services/user_service"
|
|
46
|
+
require "forem/services/comment_service"
|
|
47
|
+
require "forem/services/organization_service"
|
|
48
|
+
require "forem/services/tag_service"
|
|
49
|
+
require "forem/services/follow_service"
|
|
50
|
+
require "forem/services/follower_service"
|
|
51
|
+
require "forem/services/reading_list_service"
|
|
52
|
+
require "forem/services/podcast_episode_service"
|
|
53
|
+
require "forem/services/video_service"
|
|
54
|
+
require "forem/services/profile_image_service"
|
|
55
|
+
require "forem/services/billboard_service"
|
|
56
|
+
require "forem/services/page_service"
|
|
57
|
+
require "forem/services/segment_service"
|
|
58
|
+
require "forem/services/reaction_service"
|
|
59
|
+
require "forem/services/recommended_articles_list_service"
|
|
60
|
+
require "forem/services/agent_session_service"
|
|
61
|
+
require "forem/services/survey_service"
|
|
62
|
+
require "forem/services/analytics_service"
|
|
63
|
+
require "forem/services/health_check_service"
|
|
64
|
+
require "forem/services/admin_user_service"
|
|
65
|
+
require "forem/services/trend_service"
|
|
66
|
+
require "forem/services/concept_service"
|
|
67
|
+
require "forem/services/admin_concept_service"
|
|
68
|
+
require "forem/services/request_redirect_service"
|
|
69
|
+
require "forem/client"
|
|
70
|
+
|
|
71
|
+
# Top-level namespace for the forem-ruby gem.
|
|
72
|
+
#
|
|
73
|
+
# All API access goes through {Forem::Client}. The library does not maintain
|
|
74
|
+
# any global state — each {Client} instance carries its own configuration and
|
|
75
|
+
# {APIRequestor}, so multiple clients (e.g. for different Forem instances or
|
|
76
|
+
# different API keys) can coexist in the same process without interfering
|
|
77
|
+
# with each other.
|
|
78
|
+
#
|
|
79
|
+
# == Quick start
|
|
80
|
+
#
|
|
81
|
+
# require "forem"
|
|
82
|
+
#
|
|
83
|
+
# client = Forem::Client.new(ENV["FOREM_API_KEY"])
|
|
84
|
+
#
|
|
85
|
+
# articles = client.articles.list(per_page: 5)
|
|
86
|
+
# articles.each { |a| puts a.title }
|
|
87
|
+
#
|
|
88
|
+
# @see Forem::Client
|
|
89
|
+
# @see https://developers.forem.com/api/v1 Forem API documentation
|
|
90
|
+
module Forem
|
|
91
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: forem-ruby
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.0.beta1
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Forem
|
|
8
|
+
bindir: bin
|
|
9
|
+
cert_chain: []
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
11
|
+
dependencies: []
|
|
12
|
+
description: A Ruby client library for the Forem API, modeled after stripe-ruby patterns.
|
|
13
|
+
executables: []
|
|
14
|
+
extensions: []
|
|
15
|
+
extra_rdoc_files: []
|
|
16
|
+
files:
|
|
17
|
+
- LICENSE
|
|
18
|
+
- forem-ruby.gemspec
|
|
19
|
+
- lib/forem.rb
|
|
20
|
+
- lib/forem/api_operations/create.rb
|
|
21
|
+
- lib/forem/api_operations/delete.rb
|
|
22
|
+
- lib/forem/api_operations/list.rb
|
|
23
|
+
- lib/forem/api_operations/request.rb
|
|
24
|
+
- lib/forem/api_operations/retrieve.rb
|
|
25
|
+
- lib/forem/api_operations/save.rb
|
|
26
|
+
- lib/forem/api_operations/update.rb
|
|
27
|
+
- lib/forem/api_requestor.rb
|
|
28
|
+
- lib/forem/api_resource.rb
|
|
29
|
+
- lib/forem/client.rb
|
|
30
|
+
- lib/forem/configuration.rb
|
|
31
|
+
- lib/forem/connection_manager.rb
|
|
32
|
+
- lib/forem/errors.rb
|
|
33
|
+
- lib/forem/forem_object.rb
|
|
34
|
+
- lib/forem/forem_response.rb
|
|
35
|
+
- lib/forem/list_object.rb
|
|
36
|
+
- lib/forem/resources/admin_concept.rb
|
|
37
|
+
- lib/forem/resources/admin_user.rb
|
|
38
|
+
- lib/forem/resources/agent_session.rb
|
|
39
|
+
- lib/forem/resources/analytics.rb
|
|
40
|
+
- lib/forem/resources/article.rb
|
|
41
|
+
- lib/forem/resources/billboard.rb
|
|
42
|
+
- lib/forem/resources/comment.rb
|
|
43
|
+
- lib/forem/resources/concept.rb
|
|
44
|
+
- lib/forem/resources/follow.rb
|
|
45
|
+
- lib/forem/resources/follower.rb
|
|
46
|
+
- lib/forem/resources/health_check.rb
|
|
47
|
+
- lib/forem/resources/organization.rb
|
|
48
|
+
- lib/forem/resources/page.rb
|
|
49
|
+
- lib/forem/resources/podcast_episode.rb
|
|
50
|
+
- lib/forem/resources/profile_image.rb
|
|
51
|
+
- lib/forem/resources/reaction.rb
|
|
52
|
+
- lib/forem/resources/reading_list.rb
|
|
53
|
+
- lib/forem/resources/recommended_articles_list.rb
|
|
54
|
+
- lib/forem/resources/request_redirect.rb
|
|
55
|
+
- lib/forem/resources/segment.rb
|
|
56
|
+
- lib/forem/resources/survey.rb
|
|
57
|
+
- lib/forem/resources/tag.rb
|
|
58
|
+
- lib/forem/resources/trend.rb
|
|
59
|
+
- lib/forem/resources/user.rb
|
|
60
|
+
- lib/forem/resources/video.rb
|
|
61
|
+
- lib/forem/services/admin_concept_service.rb
|
|
62
|
+
- lib/forem/services/admin_user_service.rb
|
|
63
|
+
- lib/forem/services/agent_session_service.rb
|
|
64
|
+
- lib/forem/services/analytics_service.rb
|
|
65
|
+
- lib/forem/services/article_service.rb
|
|
66
|
+
- lib/forem/services/base_service.rb
|
|
67
|
+
- lib/forem/services/billboard_service.rb
|
|
68
|
+
- lib/forem/services/comment_service.rb
|
|
69
|
+
- lib/forem/services/concept_service.rb
|
|
70
|
+
- lib/forem/services/follow_service.rb
|
|
71
|
+
- lib/forem/services/follower_service.rb
|
|
72
|
+
- lib/forem/services/health_check_service.rb
|
|
73
|
+
- lib/forem/services/organization_service.rb
|
|
74
|
+
- lib/forem/services/page_service.rb
|
|
75
|
+
- lib/forem/services/podcast_episode_service.rb
|
|
76
|
+
- lib/forem/services/profile_image_service.rb
|
|
77
|
+
- lib/forem/services/reaction_service.rb
|
|
78
|
+
- lib/forem/services/reading_list_service.rb
|
|
79
|
+
- lib/forem/services/recommended_articles_list_service.rb
|
|
80
|
+
- lib/forem/services/request_redirect_service.rb
|
|
81
|
+
- lib/forem/services/segment_service.rb
|
|
82
|
+
- lib/forem/services/survey_service.rb
|
|
83
|
+
- lib/forem/services/tag_service.rb
|
|
84
|
+
- lib/forem/services/trend_service.rb
|
|
85
|
+
- lib/forem/services/user_service.rb
|
|
86
|
+
- lib/forem/services/video_service.rb
|
|
87
|
+
- lib/forem/util.rb
|
|
88
|
+
- lib/forem/version.rb
|
|
89
|
+
homepage: https://github.com/forem/forem-ruby
|
|
90
|
+
licenses:
|
|
91
|
+
- MIT
|
|
92
|
+
metadata:
|
|
93
|
+
rubygems_mfa_required: 'true'
|
|
94
|
+
rdoc_options: []
|
|
95
|
+
require_paths:
|
|
96
|
+
- lib
|
|
97
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
98
|
+
requirements:
|
|
99
|
+
- - ">="
|
|
100
|
+
- !ruby/object:Gem::Version
|
|
101
|
+
version: 3.1.0
|
|
102
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
103
|
+
requirements:
|
|
104
|
+
- - ">="
|
|
105
|
+
- !ruby/object:Gem::Version
|
|
106
|
+
version: '0'
|
|
107
|
+
requirements: []
|
|
108
|
+
rubygems_version: 3.6.9
|
|
109
|
+
specification_version: 4
|
|
110
|
+
summary: Ruby client for the Forem API
|
|
111
|
+
test_files: []
|