lib/portatext/command/api/campaigns.rb in portatext-1.5.19 vs lib/portatext/command/api/campaigns.rb in portatext-1.5.20
- old
+ new
@@ -46,10 +46,14 @@
def contacts
set :contacts, true
end
+ def contact(contact)
+ set :contact, contact
+ end
+
def schedule(type, details)
schedule = {}
schedule[type] = details
set :schedule, schedule
end
@@ -61,10 +65,11 @@
set :settings, args
end
# rubocop:disable Metrics/MethodLength
# rubocop:disable Metrics/AbcSize
+ # rubocop:disable Metrics/CyclomaticComplexity
def endpoint(_method)
unless @args[:file].nil?
settings = @args.clone
settings.delete :file
settings = settings.to_json
@@ -78,18 +83,22 @@
end
qs = URI.encode_www_form qs
unless @args[:id].nil?
id = @args[:id]
contacts = @args[:contacts]
+ contact = @args[:contact]
@args.delete :type
@args.delete :id
@args.delete :contacts
+ @args.delete :contact
+ return "campaigns/#{id}/contacts/#{contact}" if contact
return "campaigns/#{id}/contacts?#{qs}" if contacts
return "campaigns/#{id}"
end
return "campaigns?#{qs}" unless qs.empty?
'campaigns'
end
+ # rubocop:enable Metrics/CyclomaticComplexity
# rubocop:enable Metrics/AbcSize
# rubocop:enable Metrics/MethodLength
end
end
end