From 215a07fd48ec44d4efb972eecf4ec955c2c81e07 Mon Sep 17 00:00:00 2001 From: Jon Allured Date: Tue, 28 Mar 2023 15:34:40 -0500 Subject: [PATCH] Add list content blocks --- lib/braze_ruby/api.rb | 2 ++ lib/braze_ruby/endpoints.rb | 1 + lib/braze_ruby/endpoints/content_blocks.rb | 19 +++++++++++++ lib/braze_ruby/rest.rb | 1 + lib/braze_ruby/rest/content_blocks.rb | 11 ++++++++ .../endpoints/content_blocks_spec.rb | 28 +++++++++++++++++++ 6 files changed, 62 insertions(+) create mode 100644 lib/braze_ruby/endpoints/content_blocks.rb create mode 100644 lib/braze_ruby/rest/content_blocks.rb create mode 100644 spec/braze_ruby/endpoints/content_blocks_spec.rb diff --git a/lib/braze_ruby/api.rb b/lib/braze_ruby/api.rb index 6dc932c..53ed72e 100644 --- a/lib/braze_ruby/api.rb +++ b/lib/braze_ruby/api.rb @@ -13,6 +13,7 @@ require "braze_ruby/endpoints/rename_external_ids" require "braze_ruby/endpoints/remove_external_ids" require "braze_ruby/endpoints/remove_email_addresses_from_spam" +require "braze_ruby/endpoints/content_blocks" module BrazeRuby class API @@ -32,6 +33,7 @@ class API include BrazeRuby::Endpoints::RenameExternalIds include BrazeRuby::Endpoints::RemoveExternalIds include BrazeRuby::Endpoints::RemoveEmailAddressesFromSpam + include BrazeRuby::Endpoints::ContentBlocks def export_users(**payload) BrazeRuby::REST::ExportUsers.new(api_key, braze_url, options).perform(**payload) diff --git a/lib/braze_ruby/endpoints.rb b/lib/braze_ruby/endpoints.rb index 032303b..ad17887 100644 --- a/lib/braze_ruby/endpoints.rb +++ b/lib/braze_ruby/endpoints.rb @@ -11,3 +11,4 @@ require "braze_ruby/endpoints/rename_external_ids" require "braze_ruby/endpoints/remove_external_ids" require "braze_ruby/endpoints/remove_email_addresses_from_spam" +require "braze_ruby/endpoints/content_blocks" diff --git a/lib/braze_ruby/endpoints/content_blocks.rb b/lib/braze_ruby/endpoints/content_blocks.rb new file mode 100644 index 0000000..45b1905 --- /dev/null +++ b/lib/braze_ruby/endpoints/content_blocks.rb @@ -0,0 +1,19 @@ +# frozen_string_literal: true + +module BrazeRuby + module Endpoints + module ContentBlocks + attr_writer :content_blocks_service + + def list_content_blocks + content_blocks_service.perform + end + + private + + def content_blocks_service + @content_blocks_service ||= BrazeRuby::REST::ContentBlocks.new(api_key, braze_url, options) + end + end + end +end diff --git a/lib/braze_ruby/rest.rb b/lib/braze_ruby/rest.rb index fd45f45..dbf1b99 100644 --- a/lib/braze_ruby/rest.rb +++ b/lib/braze_ruby/rest.rb @@ -24,3 +24,4 @@ require "braze_ruby/rest/rename_external_ids" require "braze_ruby/rest/remove_external_ids" require "braze_ruby/rest/remove_email_addresses_from_spam" +require "braze_ruby/rest/content_blocks" diff --git a/lib/braze_ruby/rest/content_blocks.rb b/lib/braze_ruby/rest/content_blocks.rb new file mode 100644 index 0000000..add5eea --- /dev/null +++ b/lib/braze_ruby/rest/content_blocks.rb @@ -0,0 +1,11 @@ +# frozen_string_literal: true + +module BrazeRuby + module REST + class ContentBlocks < Base + def perform + http.get "/content_blocks/list" + end + end + end +end diff --git a/spec/braze_ruby/endpoints/content_blocks_spec.rb b/spec/braze_ruby/endpoints/content_blocks_spec.rb new file mode 100644 index 0000000..4c5324a --- /dev/null +++ b/spec/braze_ruby/endpoints/content_blocks_spec.rb @@ -0,0 +1,28 @@ +# frozen_string_literal: true + +require "spec_helper" + +class API + include BrazeRuby::Endpoints::ContentBlocks + + def api_key + :api_key + end +end + +describe BrazeRuby::Endpoints::ContentBlocks do + describe "#list_content_blocks" do + let(:api) { API.new } + let(:content_blocks_service) { double(:content_blocks_service) } + + before { api.content_blocks_service = content_blocks_service } + + it "lists content blocks" do + expect(content_blocks_service).to receive(:perform) + api.list_content_blocks + end + + # https://www.braze.com/docs/api/endpoints/templates/content_blocks_templates/get_list_email_content_blocks/ + xit "supports optional params" + end +end