Sha256: 72981b1e657d2933b1bbe87e0956977f9d4aa0fa1e365f4e7a23fe336575add9

Contents?: true

Size: 789 Bytes

Versions: 1

Compression:

Stored size: 789 Bytes

Contents

# frozen_string_literal: true

module BusinessCentral
  module Object
    class Attachments < Base
      using Refinements::Strings

      OBJECT = 'attachments'

      def initialize(client, **args)
        super(client, **args.merge!({ object_name: OBJECT }))
      end

      def update(parent_id:, attachment_id:, **params)
        url = "#{build_url}(parentId=#{parent_id},id=#{attachment_id})/content"
        Request.call(:patch, @client, url, etag: '', params: {}) do |request|
          request['Content-Type'] = 'application/json'
          request['If-Match'] = 'application/json'
          request.body = Request.convert(params)
        end
      end

      def destroy(id)
        Request.call(:delete, @client, build_url(object_id: id), etag: '')
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
business-central-2.0.0 lib/business_central/object/attachments.rb