lib/ruby_lokalise_api/rest/segments.rb in ruby-lokalise-api-7.2.0 vs lib/ruby_lokalise_api/rest/segments.rb in ruby-lokalise-api-8.0.0.rc1
- old
+ new
@@ -1,45 +1,58 @@
# frozen_string_literal: true
module RubyLokaliseApi
module Rest
module Segments
- # Returns all segments for the given key and language ISO code
+ # Returns project segments
#
# @see https://developers.lokalise.com/reference/list-all-segments-for-key-language
- # @return [RubyLokaliseApi::Collection::Segments<RubyLokaliseApi::Resources::Segment>]
+ # @return [RubyLokaliseApi::Collections::Segments]
# @param project_id [String]
# @param key_id [String, Integer]
- # @param lang_iso [String]
- # @param params [Hash]
- def segments(project_id, key_id, lang_iso, params = {})
- c_r RubyLokaliseApi::Collections::Segment, :all, [project_id, key_id, lang_iso], params
+ # @param language_iso [String]
+ # @param req_params [Hash]
+ def segments(project_id, key_id, language_iso, req_params = {})
+ name = 'Segments'
+ params = { query: [project_id, key_id, language_iso], req: req_params }
+
+ data = endpoint(name: name, params: params).do_get
+
+ collection name, data
end
- # Returns a segment under a given number for the given key and language ISO code
+ # Returns a single project segment
#
# @see https://developers.lokalise.com/reference/retrieve-a-segment-for-key-language
# @return [RubyLokaliseApi::Resources::Segment]
# @param project_id [String]
# @param key_id [String, Integer]
- # @param lang_iso [String]
- # @params segment_number [Integer, String]
- # @param params [Hash]
- def segment(project_id, key_id, lang_iso, segment_number, params = {})
- c_r RubyLokaliseApi::Resources::Segment, :find, [project_id, key_id, lang_iso, segment_number], params
+ # @param language_iso [String]
+ # @param segment_number [String, Integer]
+ # @param req_params [Hash]
+ def segment(project_id, key_id, language_iso, segment_number, req_params = {})
+ params = { query: [project_id, key_id, language_iso, segment_number], req: req_params }
+
+ data = endpoint(name: 'Segments', params: params).do_get
+
+ resource 'Segment', data
end
- # Updates a segment under a given number for the given key and language ISO code
+ # Updates a segment
#
# @see https://developers.lokalise.com/reference/update-a-segment
# @return [RubyLokaliseApi::Resources::Segment]
# @param project_id [String]
# @param key_id [String, Integer]
- # @param lang_iso [String]
- # @params segment_number [Integer, String]
- # @param params [Hash]
- def update_segment(project_id, key_id, lang_iso, segment_number, params = {})
- c_r RubyLokaliseApi::Resources::Segment, :update, [project_id, key_id, lang_iso, segment_number], params
+ # @param language_iso [String]
+ # @param segment_number [String, Integer]
+ # @param req_params [Hash]
+ def update_segment(project_id, key_id, language_iso, segment_number, req_params = {})
+ params = { query: [project_id, key_id, language_iso, segment_number], req: req_params }
+
+ data = endpoint(name: 'Segments', params: params).do_put
+
+ resource 'Segment', data
end
end
end
end