opossum 0.3.0 → 0.4.0

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: f835a756ad086cea7eb54dfbb798975cff69dd6d78b4d2b756a5eb9870818196
4
- data.tar.gz: ee8f5c575cb49aa93002d00b955fd910029b752aee738464fc13c9d877e069c1
3
+ metadata.gz: 721a81517304c17e172662c5fbd1e055dd3d218658749d04efd02191cb866eb6
4
+ data.tar.gz: 006cdb6681a963740d03d62dd566f2a3323027556dacc8591afc6c3e8732fcc6
5
5
  SHA512:
6
- metadata.gz: cbb2cb21287e5a5bf0547cf826a7c2f0f2fbf38dca6ae6651bec2ccc44190da8b2b2953c36a46be7df521ad565deadfd6e2ebdee988565c454f676e7d138db8e
7
- data.tar.gz: 94a6445ba81cb9fe6450b600701e54bb69227c7ebb2a147b01857a40907a9e31fd7cd16757fc972c83822f4f517c372f6fd15ea4cf61424dd16f6370f50a350b
6
+ metadata.gz: 23a6aa7fe4861ca4c62eb3a293fe4d507c2b33d479253b1340cddf561f97a43827170fa29d4b7a8f3db2b72fc739a3423fea49645d88ede37f0b443e5fd47170
7
+ data.tar.gz: 7ce15a3f0382aa0b57671c6aa62fc53f1dec2c214e52a90bfec640f2ef2d8fb209d64d42c26abc5f28d2bbc01090979f6ca25136078e0d6a3772fd55ba3402cb
data/CHANGELOG.md CHANGED
@@ -1,3 +1,16 @@
1
+ ## [0.4.0] - 2026-10-06
2
+
3
+ ### Added
4
+ - **Image stories** - `Publisher#publish_media` accepts `media_format: "IMAGE" | "VIDEO"` for `media_type: "STORIES"`
5
+ - `"IMAGE"` sends the media URL as `image_url`; `"VIDEO"` (and the default, unchanged) as `video_url`
6
+ - Other media types ignore `media_format`
7
+
8
+ ## [0.3.1] - 2025-01-27
9
+
10
+ ### Fixed
11
+ - **API Error Handling** - Improved error handling in ApiHelper
12
+ - Enhanced error message extraction with fallback to nested error structure
13
+
1
14
  ## [0.3.0] - 2025-08-12
2
15
 
3
16
  ### Improved
@@ -66,7 +79,7 @@
66
79
  ### Added
67
80
 
68
81
  #### Core Architecture
69
- - **Authenticator class** - OAuth authentication with Instagram Basic Display API
82
+ - **Authenticator class** - OAuth authentication with Instagram API with Instagram Login
70
83
  - Exchange authorization code for access token
71
84
  - Support for client credentials and redirect URI configuration
72
85
 
data/README.md CHANGED
@@ -1,13 +1,13 @@
1
1
  # OpossumInstagramPublisher
2
2
 
3
- A Ruby gem for publishing media to Instagram using Instagram Basic Display API and Instagram Graph API. This gem provides a simple interface to authenticate users via Instagram Login and publish images, videos, and carousel posts to their Instagram accounts.
3
+ A Ruby gem for publishing media to Instagram using Instagram API with Instagram Login. This gem provides a simple interface to authenticate users via Instagram Login and publish images, videos, and carousel posts to their Instagram accounts.
4
4
 
5
5
  ## Prerequisites
6
6
 
7
7
  Before using this gem, you need to:
8
8
 
9
- 1. Create a Facebook App and configure Instagram Basic Display API
10
- 2. Set up Instagram Basic Display API permissions
9
+ 1. Create a Facebook App and configure Instagram API with Instagram Login
10
+ 2. Set up Instagram API with Instagram Login permissions
11
11
  3. Configure OAuth redirect URIs in your Facebook App settings
12
12
  4. Obtain your Instagram Business Account ID
13
13
 
@@ -121,6 +121,13 @@ result = publisher.publish_media(
121
121
  caption: 'Photo collection from my trip ✈️ #travel #memories'
122
122
  )
123
123
 
124
+ # Publish a story (media_format picks image_url vs video_url; default is VIDEO)
125
+ result = publisher.publish_media(
126
+ media_url: 'https://example.com/story.jpg',
127
+ media_type: 'STORIES',
128
+ media_format: 'IMAGE'
129
+ )
130
+
124
131
  # That's it! publish_media handles everything automatically:
125
132
  # - Creates media container(s)
126
133
  # - Waits for processing to complete
@@ -163,7 +170,7 @@ end
163
170
  - **IMAGE** - Single images (JPEG, PNG) with optional caption
164
171
  - **VIDEO** - Single videos (MP4, MOV) with optional caption
165
172
  - **REELS** - Instagram Reels with optional caption
166
- - **STORIES** - Instagram Stories with optional caption
173
+ - **STORIES** - Instagram Stories; pass `media_format: 'IMAGE'` or `'VIDEO'` (default) to choose the URL field
167
174
  - **CAROUSEL** - Multiple images in a single post with optional caption (automatically handled when passing an array of URLs)
168
175
 
169
176
  **Features:**
@@ -57,7 +57,7 @@ module Opossum
57
57
  raise Opossum::Error.new(
58
58
  "Instagram API Error: #{error_message}",
59
59
  code: parsed_response.dig("error", "code"),
60
- subcode: parsed_response.dig("error", "subcode")
60
+ subcode: parsed_response.dig("error", "subcode") || parsed_response.dig("error", "error_subcode")
61
61
  )
62
62
  end
63
63
  end
@@ -12,9 +12,12 @@ module Opossum
12
12
  @ig_id = ig_id
13
13
  end
14
14
 
15
- def publish_media(media_url:, media_type: "IMAGE", caption: nil)
15
+ # media_format applies to STORIES only: "IMAGE" sends the url as image_url,
16
+ # "VIDEO" (the default) as video_url. Other media types ignore it.
17
+ def publish_media(media_url:, media_type: "IMAGE", caption: nil, media_format: nil)
16
18
  path = "#{INSTAGRAM_GRAPH_API_ENDPOINT}/#{GRAPH_API_VERSION}/#{ig_id}/media_publish"
17
- media_container_id = prepare_media_container(media_url: media_url, media_type: media_type, caption: caption)
19
+ media_container_id = prepare_media_container(media_url: media_url, media_type: media_type, caption: caption,
20
+ media_format: media_format)
18
21
 
19
22
  ApiHelper.post(
20
23
  path: path,
@@ -26,11 +29,12 @@ module Opossum
26
29
 
27
30
  attr_reader :ig_id
28
31
 
29
- def prepare_media_container(media_url:, media_type:, caption:)
32
+ def prepare_media_container(media_url:, media_type:, caption:, media_format: nil)
30
33
  if media_url.is_a?(Array)
31
34
  prepare_carousel_media(media_urls: media_url, media_type: media_type, caption: caption)
32
35
  else
33
- create_media_container(media_url: media_url, media_type: media_type, caption: caption)
36
+ create_media_container(media_url: media_url, media_type: media_type, caption: caption,
37
+ media_format: media_format)
34
38
  end
35
39
  end
36
40
 
@@ -46,10 +50,10 @@ module Opossum
46
50
  create_media_container(media_url: children_ids, media_type: media_type, caption: caption)
47
51
  end
48
52
 
49
- def create_media_container(media_url:, media_type: "IMAGE", is_carousel_item: false, upload_type: nil, caption: nil)
53
+ # options: is_carousel_item:, upload_type:, media_format:
54
+ def create_media_container(media_url:, media_type: "IMAGE", caption: nil, **options)
50
55
  path = "#{INSTAGRAM_GRAPH_API_ENDPOINT}/#{GRAPH_API_VERSION}/#{ig_id}/media"
51
- body = build_media_container_body(media_url: media_url, media_type: media_type, caption: caption,
52
- is_carousel_item: is_carousel_item, upload_type: upload_type)
56
+ body = build_media_container_body(media_url: media_url, media_type: media_type, caption: caption, **options)
53
57
 
54
58
  response = ApiHelper.post(path: path, body: body)
55
59
  media_container_id = response["id"]
@@ -58,20 +62,22 @@ module Opossum
58
62
  media_container_id
59
63
  end
60
64
 
61
- def build_media_container_body(media_url:, media_type:, caption:, is_carousel_item:, upload_type:)
65
+ def build_media_container_body(media_url:, media_type:, caption:, **options)
62
66
  body = { access_token: access_token, media_type: media_type, caption: caption }
63
- set_media_url_field(body, media_url, media_type)
64
- body[:is_carousel_item] = is_carousel_item if is_carousel_item
65
- body[:upload_type] = upload_type if upload_type
67
+ set_media_url_field(body, media_url, media_type, options[:media_format])
68
+ body[:is_carousel_item] = options[:is_carousel_item] if options[:is_carousel_item]
69
+ body[:upload_type] = options[:upload_type] if options[:upload_type]
66
70
  body
67
71
  end
68
72
 
69
- def set_media_url_field(body, media_url, media_type)
73
+ def set_media_url_field(body, media_url, media_type, media_format = nil)
70
74
  case media_type
71
75
  when "IMAGE"
72
76
  body[:image_url] = media_url
73
- when "VIDEO", "REELS", "STORIES"
77
+ when "VIDEO", "REELS"
74
78
  body[:video_url] = media_url
79
+ when "STORIES"
80
+ body[media_format.to_s.upcase == "IMAGE" ? :image_url : :video_url] = media_url
75
81
  when "CAROUSEL"
76
82
  body[:children] = media_url
77
83
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Opossum
4
- VERSION = "0.3.0"
4
+ VERSION = "0.4.0"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: opossum
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vadym Kruchyna
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2025-08-12 00:00:00.000000000 Z
11
+ date: 2026-10-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -133,6 +133,6 @@ requirements: []
133
133
  rubygems_version: 3.5.22
134
134
  signing_key:
135
135
  specification_version: 4
136
- summary: Ruby gem for publishing media to Instagram using Instagram Basic Display
137
- API
136
+ summary: Ruby gem for publishing media to Instagram using Instagram API with Instagram
137
+ Login
138
138
  test_files: []