opossum 0.2.0 → 0.3.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: 28f90ba90661894c077eb72004e0300f07e9c2d93059d8221985c396b467b74e
4
- data.tar.gz: 29afd0da8dd9f9192caeea525f92365637b75d15816fca846a0a577049ea56d9
3
+ metadata.gz: f835a756ad086cea7eb54dfbb798975cff69dd6d78b4d2b756a5eb9870818196
4
+ data.tar.gz: ee8f5c575cb49aa93002d00b955fd910029b752aee738464fc13c9d877e069c1
5
5
  SHA512:
6
- metadata.gz: cf6f1c1f02604906beb4ea09fb3af644ede569c4ec9dcf962a6f2d851f2ee5fbfedd4a2ade0831b0a677b8ae78e51ced66a919eb12237820658b74014c150d5f
7
- data.tar.gz: ccba27fcb4c858e825ca63f494ab97d6246e58078a4369274373170dab71cb11e20dcec00789e924dc52312c696f1073b740a27bd76e99c6e3659dc6e49227c8
6
+ metadata.gz: cbb2cb21287e5a5bf0547cf826a7c2f0f2fbf38dca6ae6651bec2ccc44190da8b2b2953c36a46be7df521ad565deadfd6e2ebdee988565c454f676e7d138db8e
7
+ data.tar.gz: 94a6445ba81cb9fe6450b600701e54bb69227c7ebb2a147b01857a40907a9e31fd7cd16757fc972c83822f4f517c372f6fd15ea4cf61424dd16f6370f50a350b
data/CHANGELOG.md CHANGED
@@ -1,3 +1,24 @@
1
+ ## [0.3.0] - 2025-08-12
2
+
3
+ ### Improved
4
+ - **Publisher Performance** - Enhanced carousel media processing with parallel execution
5
+ - `prepare_carousel_media` now uses Thread-based parallel processing for media container creation
6
+ - Significantly improved upload speed for carousels with multiple media items
7
+ - Each media URL in carousel is processed concurrently instead of sequentially
8
+ - **Error Handling** - Enhanced Error class with additional error context
9
+ - Added `code` and `subcode` attributes to Error class for better error identification
10
+ - Improved error initialization with optional code and subcode parameters
11
+
12
+ ## [0.2.1] - 2025-08-07
13
+
14
+ ### Improved
15
+ - **Instagram API Response Handling** - Enhanced error handling and response processing
16
+ - Improved JSON parsing with better error messages when API returns invalid JSON
17
+ - Added specific Instagram API error detection and messaging via `error_message` field
18
+ - Enhanced HTTP error handling with more descriptive error messages
19
+ - Better separation of concerns in ApiHelper with dedicated private methods for response processing
20
+ - More robust error handling chain: HTTP errors → JSON parsing errors → Instagram API errors
21
+
1
22
  ## [0.2.0] - 2025-08-06
2
23
 
3
24
  ### Changed
data/README.md CHANGED
@@ -131,7 +131,7 @@ result = publisher.publish_media(
131
131
 
132
132
  ## Error Handling
133
133
 
134
- The gem includes comprehensive error handling for API responses:
134
+ The gem includes comprehensive error handling for API responses with enhanced Instagram API error detection:
135
135
 
136
136
  ```ruby
137
137
  begin
@@ -145,9 +145,19 @@ begin
145
145
  )
146
146
  rescue Opossum::Error => e
147
147
  puts "Error: #{e.message}"
148
+ # Examples of error messages:
149
+ # "HTTP Error: Connection failed"
150
+ # "JSON Parse Error: Unexpected token"
151
+ # "Instagram API Error: Invalid media URL"
148
152
  end
149
153
  ```
150
154
 
155
+ **Error Handling Features:**
156
+ - **HTTP Error Detection** - Catches network and connection issues with descriptive messages
157
+ - **JSON Parsing** - Handles malformed API responses with clear error descriptions
158
+ - **Instagram API Errors** - Automatically detects and reports Instagram-specific errors via `error_message` field
159
+ - **Error Chain Processing** - Processes errors in logical order: HTTP → JSON → Instagram API
160
+
151
161
  ## Supported Media Types
152
162
 
153
163
  - **IMAGE** - Single images (JPEG, PNG) with optional caption
@@ -36,10 +36,8 @@ module Opossum
36
36
  end
37
37
 
38
38
  def handle_response(response)
39
- raise Opossum::Error, "HTTP #{response.status}: #{response.body}" unless response.success?
40
-
41
39
  parsed_response = parse_json(response.body)
42
- check_api_errors(parsed_response)
40
+ check_api_errors(parsed_response, response.success?)
43
41
  parsed_response
44
42
  rescue Faraday::Error => e
45
43
  raise Opossum::Error, "HTTP Error: #{e.message}"
@@ -51,12 +49,16 @@ module Opossum
51
49
  raise Opossum::Error, "JSON Parse Error: #{e.message}"
52
50
  end
53
51
 
54
- def check_api_errors(parsed_response)
55
- return unless parsed_response["error"]
52
+ def check_api_errors(parsed_response, success)
53
+ return if success
54
+
55
+ error_message = parsed_response["error_message"] || parsed_response.dig("error", "message")
56
56
 
57
- error_message = "Instagram API Error: #{parsed_response["error"]}"
58
- error_message += " - #{parsed_response["error_description"]}" if parsed_response["error_description"]
59
- raise Opossum::Error, error_message
57
+ raise Opossum::Error.new(
58
+ "Instagram API Error: #{error_message}",
59
+ code: parsed_response.dig("error", "code"),
60
+ subcode: parsed_response.dig("error", "subcode")
61
+ )
60
62
  end
61
63
  end
62
64
  end
@@ -35,10 +35,14 @@ module Opossum
35
35
  end
36
36
 
37
37
  def prepare_carousel_media(media_urls:, media_type:, caption:)
38
- children_ids = media_urls.map do |url|
39
- create_media_container(media_url: url, is_carousel_item: true, caption: caption)
38
+ threads = media_urls.map do |url|
39
+ Thread.new do
40
+ create_media_container(media_url: url, is_carousel_item: true, caption: caption)
41
+ end
40
42
  end
41
43
 
44
+ children_ids = threads.map(&:value)
45
+
42
46
  create_media_container(media_url: children_ids, media_type: media_type, caption: caption)
43
47
  end
44
48
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Opossum
4
- VERSION = "0.2.0"
4
+ VERSION = "0.3.0"
5
5
  end
data/lib/opossum.rb CHANGED
@@ -6,5 +6,15 @@ require_relative "opossum/user_details"
6
6
  require_relative "opossum/publisher"
7
7
 
8
8
  module Opossum
9
- class Error < StandardError; end
9
+ # Custom error class for Opossum gem
10
+ class Error < StandardError
11
+ attr_reader :code, :subcode
12
+
13
+ def initialize(message, code: nil, subcode: nil)
14
+ super(message)
15
+
16
+ @code = code
17
+ @subcode = subcode
18
+ end
19
+ end
10
20
  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.2.0
4
+ version: 0.3.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-06 00:00:00.000000000 Z
11
+ date: 2025-08-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday