shopify_api 4.9.0 → 6.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.github/CODEOWNERS +1 -0
- data/.github/probots.yml +2 -0
- data/.gitignore +3 -0
- data/.rubocop.yml +8 -0
- data/.travis.yml +0 -4
- data/CHANGELOG +67 -0
- data/README.md +48 -26
- data/lib/active_resource/detailed_log_subscriber.rb +25 -2
- data/lib/shopify_api/connection.rb +5 -3
- data/lib/shopify_api/limits.rb +1 -2
- data/lib/shopify_api/resources/abandoned_checkout.rb +7 -0
- data/lib/shopify_api/resources/access_scope.rb +5 -0
- data/lib/shopify_api/resources/api_permission.rb +9 -0
- data/lib/shopify_api/resources/asset.rb +8 -8
- data/lib/shopify_api/resources/billing_address.rb +1 -1
- data/lib/shopify_api/resources/checkout.rb +27 -1
- data/lib/shopify_api/resources/collection_publication.rb +10 -0
- data/lib/shopify_api/resources/currency.rb +6 -0
- data/lib/shopify_api/resources/custom_collection.rb +3 -3
- data/lib/shopify_api/resources/{customer_invite_message.rb → customer_invite.rb} +0 -0
- data/lib/shopify_api/resources/graphql.rb +22 -0
- data/lib/shopify_api/resources/image.rb +2 -2
- data/lib/shopify_api/resources/inventory_item.rb +6 -0
- data/lib/shopify_api/resources/inventory_level.rb +55 -0
- data/lib/shopify_api/resources/line_item.rb +9 -1
- data/lib/shopify_api/resources/location.rb +4 -0
- data/lib/shopify_api/resources/o_auth.rb +8 -0
- data/lib/shopify_api/resources/order.rb +16 -4
- data/lib/shopify_api/resources/payment.rb +7 -0
- data/lib/shopify_api/resources/ping.rb +3 -0
- data/lib/shopify_api/resources/ping/conversation.rb +42 -0
- data/lib/shopify_api/resources/ping/delivery_confirmation_details.rb +10 -0
- data/lib/shopify_api/resources/ping/message.rb +8 -0
- data/lib/shopify_api/resources/product.rb +4 -4
- data/lib/shopify_api/resources/product_publication.rb +10 -0
- data/lib/shopify_api/resources/publication.rb +5 -0
- data/lib/shopify_api/resources/shipping_line.rb +1 -1
- data/lib/shopify_api/resources/shipping_rate.rb +7 -0
- data/lib/shopify_api/resources/shop.rb +4 -4
- data/lib/shopify_api/resources/smart_collection.rb +6 -2
- data/lib/shopify_api/resources/tender_transaction.rb +6 -0
- data/lib/shopify_api/session.rb +16 -17
- data/lib/shopify_api/version.rb +1 -1
- data/service.yml +8 -0
- data/shopify_api.gemspec +4 -1
- data/test/abandoned_checkouts_test.rb +29 -0
- data/test/api_permission_test.rb +9 -0
- data/test/checkouts_test.rb +72 -4
- data/test/collection_publication_test.rb +40 -0
- data/test/currency_test.rb +21 -0
- data/test/detailed_log_subscriber_test.rb +19 -1
- data/test/fixtures/abandoned_checkout.json +184 -0
- data/test/fixtures/abandoned_checkouts.json +186 -0
- data/test/fixtures/checkout.json +160 -0
- data/test/fixtures/checkouts.json +25 -49
- data/test/fixtures/collection_publication.json +11 -0
- data/test/fixtures/collection_publications.json +13 -0
- data/test/fixtures/currencies.json +25 -0
- data/test/fixtures/inventory_level.json +7 -0
- data/test/fixtures/inventory_levels.json +24 -0
- data/test/fixtures/order_with_properties.json +373 -0
- data/test/fixtures/payment.json +7 -0
- data/test/fixtures/payments.json +9 -0
- data/test/fixtures/ping/conversation.json +1 -0
- data/test/fixtures/ping/failed_delivery_confirmation.json +1 -0
- data/test/fixtures/ping/message.json +1 -0
- data/test/fixtures/ping/successful_delivery_confirmation.json +1 -0
- data/test/fixtures/product_publication.json +11 -0
- data/test/fixtures/product_publications.json +13 -0
- data/test/fixtures/publications.json +9 -0
- data/test/fixtures/shipping_rates.json +12 -0
- data/test/fixtures/smart_collection_products.json +155 -0
- data/test/fixtures/tender_transactions.json +52 -0
- data/test/inventory_level_test.rb +59 -0
- data/test/location_test.rb +14 -0
- data/test/order_test.rb +29 -1
- data/test/payment_test.rb +19 -0
- data/test/ping/conversation_test.rb +71 -0
- data/test/ping/message_test.rb +23 -0
- data/test/product_publication_test.rb +40 -0
- data/test/product_test.rb +10 -0
- data/test/publication_test.rb +12 -0
- data/test/session_test.rb +11 -37
- data/test/shipping_rate_test.rb +17 -0
- data/test/smart_collection_test.rb +25 -0
- data/test/tender_transaction_test.rb +18 -0
- data/test/test_helper.rb +8 -5
- data/test/variant_test.rb +4 -1
- metadata +102 -10
- data/lib/shopify_api/resources/discount.rb +0 -11
- data/test/discount_test.rb +0 -52
- data/test/fixtures/discount.json +0 -17
- data/test/fixtures/discount_disabled.json +0 -17
- data/test/fixtures/discounts.json +0 -34
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 7b0ab297c1e32ac84d673b04ddf366cc5f9d43f2eb6f060d70e5d1fcc7c8736f
|
4
|
+
data.tar.gz: 99a2583bf370e73c85f2b71c4b6e99f1ac2e37db2a628a30dcbed346c29bdf8a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 94e653b2a765e962ba1f4c360308bab8a66bb32b8fe487def7ef9880c4b972f934f280fce5805a7f5dcdea60b2a591c0ff4ea87dff04ce6334d490506155aa5a
|
7
|
+
data.tar.gz: 13701b452c87df0a9fb4054857f37d5821b63bb0ee8e467556bc8bb1d5beeae0712ec2457462567a45a715bc8b5a60d68aad8811385d9353e61779bec68bf060
|
data/.github/CODEOWNERS
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
* @shopify/platform-dev-tools-education
|
data/.github/probots.yml
ADDED
data/.gitignore
CHANGED
data/.rubocop.yml
ADDED
data/.travis.yml
CHANGED
@@ -2,7 +2,6 @@ language: ruby
|
|
2
2
|
sudo: false
|
3
3
|
|
4
4
|
rvm:
|
5
|
-
- '2.0'
|
6
5
|
- 2.3.1
|
7
6
|
- 2.4.0-preview1
|
8
7
|
|
@@ -15,9 +14,6 @@ gemfile:
|
|
15
14
|
- Gemfile_ar_master
|
16
15
|
|
17
16
|
matrix:
|
18
|
-
exclude:
|
19
|
-
- rvm: '2.0'
|
20
|
-
gemfile: Gemfile_ar_master
|
21
17
|
fast_finish: true
|
22
18
|
allow_failures:
|
23
19
|
- rvm: 2.4.0-preview1
|
data/CHANGELOG
CHANGED
@@ -1,3 +1,70 @@
|
|
1
|
+
== Version 6.0.0
|
2
|
+
|
3
|
+
* Removed undocumented `protocol` and `port` options from `ShopifyAPI::Session`.
|
4
|
+
|
5
|
+
== Version 5.2.4
|
6
|
+
|
7
|
+
* Added `currency` parameter to `ShopifyAPI::Order#capture`. This parameter is required for apps that belong to the
|
8
|
+
multi-currency beta program.
|
9
|
+
|
10
|
+
== Version 5.2.3
|
11
|
+
|
12
|
+
* Update delivery confirmation resource to delivery confirmation details resource.
|
13
|
+
|
14
|
+
== Version 5.2.2
|
15
|
+
|
16
|
+
* Add delivery confirmation endpoint to Ping resources.
|
17
|
+
|
18
|
+
== Version 5.2.1
|
19
|
+
|
20
|
+
* Log warning when Shopify indicates deprecated API call was performed
|
21
|
+
|
22
|
+
== Version 5.2.0
|
23
|
+
|
24
|
+
* Added `ShopifyAPI::Currency` to fetch list of supported currencies on a shop
|
25
|
+
* Added `ShopifyAPI::TenderTransaction` to fetch list of transactions on a shop
|
26
|
+
* Fixed bug with X-Shopify-Checkout-Version on ShopifyAPI::Checkout header being applied to all requests
|
27
|
+
|
28
|
+
== Version 5.1.0
|
29
|
+
|
30
|
+
* Added `ShopifyAPI::Publications`
|
31
|
+
* Added `ShopifyAPI::ProductPublications`
|
32
|
+
* Added `ShopifyAPI::CollectionPublications`
|
33
|
+
* Added support for new collection products endpoint from `ShopifyAPI::Collection#products`
|
34
|
+
|
35
|
+
== Version 5.0.0
|
36
|
+
|
37
|
+
* Breaking change: `ShopifyAPI::Checkout` now maps to the Checkout API, rather than the Abandoned Checkouts API
|
38
|
+
* See the README for more details
|
39
|
+
* Added `ShopifyAPI::AbandonedCheckout`
|
40
|
+
* Added support for X-Shopify-Checkout-Version header on `ShopifyAPI::Checkout`
|
41
|
+
* Added `ShopifyAPI::ShippingRate`
|
42
|
+
* Added `ShopifyAPI::Payment`
|
43
|
+
* Added support for `Checkout::complete` endpoint
|
44
|
+
* Fixed session handling support for Rails 5.2.1
|
45
|
+
|
46
|
+
== Version 4.13.0
|
47
|
+
* Added `ShopifyAPI::ApiPermission` resource for uninstalling an application
|
48
|
+
* Added a deprecation warning to `ShopifyAPI::OAuth`
|
49
|
+
|
50
|
+
== Version 4.12.0
|
51
|
+
|
52
|
+
* Added support for the GraphQL API
|
53
|
+
|
54
|
+
== Version 4.11.0
|
55
|
+
|
56
|
+
* Added `ShopifyAPI::InventoryItem`
|
57
|
+
* Added `ShopifyAPI::InventoryLevel`
|
58
|
+
* Added `#inventory_levels` method to `ShopifyAPI::Location`
|
59
|
+
|
60
|
+
== Version 4.10.0
|
61
|
+
|
62
|
+
* Added `ShopifyAPI::AccessScope`
|
63
|
+
|
64
|
+
== Version 4.9.1
|
65
|
+
|
66
|
+
* Fix a bug with custom properties for orders
|
67
|
+
|
1
68
|
== Version 4.9.0
|
2
69
|
|
3
70
|
* Added `ShopifyAPI::PriceRule`
|
data/README.md
CHANGED
@@ -10,6 +10,13 @@ The Shopify API gem allows Ruby developers to programmatically access the admin
|
|
10
10
|
|
11
11
|
The API is implemented as JSON over HTTP using all four verbs (GET/POST/PUT/DELETE). Each resource, like Order, Product, or Collection, has its own URL and is manipulated in isolation. In other words, we’ve tried to make the API follow the REST principles as much as possible.
|
12
12
|
|
13
|
+
## ⚠️ Breaking change notice for version 5.0.0 ⚠️
|
14
|
+
The [Abandoned Checkout API](https://help.shopify.com/en/api/reference/orders/abandoned_checkouts) is now accessed through the `ShopifyAPI::AbandonedCheckout` resource. If you were previously accessing the Abandoned Checkout API through the `ShopifyAPI::Checkout` resource, you will need to update your code after upgrading from version 4.x.x or earlier.
|
15
|
+
|
16
|
+
Going forward, the `ShopifyAPI::Checkout` resource is used to access the [Checkout API](https://help.shopify.com/en/api/reference/sales_channels/checkout), which can be used to create new checkouts.
|
17
|
+
|
18
|
+
For more details, [please see this issue](https://github.com/Shopify/shopify_api/issues/471).
|
19
|
+
|
13
20
|
## Usage
|
14
21
|
|
15
22
|
### Requirements
|
@@ -19,7 +26,7 @@ All API usage happens through Shopify applications, created by either shop owner
|
|
19
26
|
* Shop owners can create applications for themselves through their own admin: https://docs.shopify.com/api/authentication/creating-a-private-app
|
20
27
|
* Shopify Partners create applications through their admin: http://app.shopify.com/services/partners
|
21
28
|
|
22
|
-
For more information and detailed documentation about the API visit
|
29
|
+
For more information and detailed documentation about the API visit https://developers.shopify.com/
|
23
30
|
|
24
31
|
#### Ruby version
|
25
32
|
|
@@ -39,15 +46,6 @@ Or install via [gem](http://rubygems.org/)
|
|
39
46
|
gem install shopify_api
|
40
47
|
```
|
41
48
|
|
42
|
-
#### Rails 5
|
43
|
-
|
44
|
-
shopify_api is compatible with Rails 5 but since the latest ActiveResource release (4.1) is locked on Rails 4.x, you'll need to use the unreleased master version:
|
45
|
-
|
46
|
-
```ruby
|
47
|
-
gem 'shopify_api'
|
48
|
-
gem 'activeresource', github: 'rails/activeresource'
|
49
|
-
```
|
50
|
-
|
51
49
|
### Getting Started
|
52
50
|
|
53
51
|
ShopifyAPI uses ActiveResource to communicate with the REST web service. ActiveResource has to be configured with a fully authorized URL of a particular store first. To obtain that URL you can follow these steps:
|
@@ -90,20 +88,20 @@ ShopifyAPI uses ActiveResource to communicate with the REST web service. ActiveR
|
|
90
88
|
We've added the create_permission_url method to make this easier, first instantiate your session object:
|
91
89
|
|
92
90
|
```ruby
|
93
|
-
|
91
|
+
shopify_session = ShopifyAPI::Session.new("SHOP_NAME.myshopify.com")
|
94
92
|
```
|
95
93
|
|
96
94
|
Then call:
|
97
95
|
|
98
96
|
```ruby
|
99
97
|
scope = ["write_products"]
|
100
|
-
permission_url =
|
98
|
+
permission_url = shopify_session.create_permission_url(scope)
|
101
99
|
```
|
102
100
|
|
103
101
|
or if you want a custom redirect_uri:
|
104
102
|
|
105
103
|
```ruby
|
106
|
-
permission_url =
|
104
|
+
permission_url = shopify_session.create_permission_url(scope, "https://my_redirect_uri.com")
|
107
105
|
```
|
108
106
|
|
109
107
|
4. Once authorized, the shop redirects the owner to the return URL of your application with a parameter named 'code'. This is a temporary token that the app can exchange for a permanent access token.
|
@@ -133,37 +131,37 @@ ShopifyAPI uses ActiveResource to communicate with the REST web service. ActiveR
|
|
133
131
|
the params, extract the temp code and then request your token:
|
134
132
|
|
135
133
|
```ruby
|
136
|
-
token =
|
134
|
+
token = shopify_session.request_token(params)
|
137
135
|
```
|
138
136
|
|
139
137
|
This method will save the token to the session object and return it. All fields returned by Shopify, other than the access token itself, are stored in the session's `extra` attribute. For a list of all fields returned by Shopify, read [our OAuth documentation](https://help.shopify.com/api/guides/authentication/oauth#confirming-installation). If you requested an access token that is associated with a specific user, you can retreive information about this user from the `extra` hash:
|
140
138
|
|
141
139
|
```ruby
|
142
140
|
# a list of all granted scopes
|
143
|
-
granted_scopes =
|
141
|
+
granted_scopes = shopify_session.extra['scope']
|
144
142
|
# a hash containing the user information
|
145
|
-
user =
|
143
|
+
user = shopify_session.extra['associated_user']
|
146
144
|
# the access scopes available to this user, which may be a subset of the access scopes granted to this app.
|
147
|
-
active_scopes =
|
145
|
+
active_scopes = shopify_session.extra['associated_user_scope']
|
148
146
|
# the time at which this token expires; this is automatically converted from 'expires_in' returned by Shopify
|
149
|
-
expires_at =
|
147
|
+
expires_at = shopify_session.extra['expires_at']
|
150
148
|
```
|
151
149
|
|
152
150
|
For the security of your application, after retrieving an access token you must validate the following:
|
153
|
-
1) The list of scopes in `
|
154
|
-
2) If you requested an online-mode access token, `
|
151
|
+
1) The list of scopes in `shopify_session.extra['scope']` is the same as you requested.
|
152
|
+
2) If you requested an online-mode access token, `shopify_session.extra['associated_user']` must be present.
|
155
153
|
Failing either of these tests means the end-user may have tampered with the url parameters during the OAuth authentication phase. You should avoid using this access token and revoke it immediately. If you use the [`omniauth-shopify-oauth2`](https://github.com/Shopify/omniauth-shopify-oauth2) gem these checks are done automatically for you.
|
156
154
|
|
157
155
|
For future sessions simply pass in the `token` and `extra` hash (optional) when creating the session object:
|
158
156
|
|
159
157
|
```ruby
|
160
|
-
|
158
|
+
shopify_session = ShopifyAPI::Session.new("SHOP_NAME.myshopify.com", token, extra)
|
161
159
|
```
|
162
160
|
|
163
161
|
5. The session must be activated before use:
|
164
162
|
|
165
163
|
```ruby
|
166
|
-
ShopifyAPI::Base.activate_session(
|
164
|
+
ShopifyAPI::Base.activate_session(shopify_session)
|
167
165
|
```
|
168
166
|
|
169
167
|
6. Now you're ready to make authorized API requests to your shop! Data is returned as ActiveResource instances:
|
@@ -230,6 +228,30 @@ gem install shopify_cli
|
|
230
228
|
shopify-cli help
|
231
229
|
```
|
232
230
|
|
231
|
+
## GraphQL
|
232
|
+
|
233
|
+
This library also supports Shopify's new [GraphQL API](https://help.shopify.com/api/graphql-admin-api)
|
234
|
+
via a dependency on the [graphql-client](https://github.com/github/graphql-client) gem.
|
235
|
+
The authentication process (steps 1-5 under [Getting Started](#getting-started))
|
236
|
+
is identical. Once your session is activated, simply construct a new graphql
|
237
|
+
client and use `parse` and `query` as defined by
|
238
|
+
[graphql-client](https://github.com/github/graphql-client#defining-queries).
|
239
|
+
|
240
|
+
```ruby
|
241
|
+
client = ShopifyAPI::GraphQL.new
|
242
|
+
|
243
|
+
SHOP_NAME_QUERY = client.parse <<-'GRAPHQL'
|
244
|
+
{
|
245
|
+
shop {
|
246
|
+
name
|
247
|
+
}
|
248
|
+
}
|
249
|
+
GRAPHQL
|
250
|
+
|
251
|
+
result = client.query(SHOP_NAME_QUERY)
|
252
|
+
result.data.shop.name
|
253
|
+
```
|
254
|
+
|
233
255
|
## Threadsafety
|
234
256
|
|
235
257
|
ActiveResource is threadsafe as of version 4.1 (which works with Rails 4.x and above).
|
@@ -241,14 +263,14 @@ If you were previously using Shopify's [activeresource fork](https://github.com/
|
|
241
263
|
Download the source code and run:
|
242
264
|
|
243
265
|
```bash
|
244
|
-
|
266
|
+
bundle install
|
267
|
+
bundle exec rake test
|
245
268
|
```
|
246
269
|
|
247
270
|
## Additional Resources
|
248
271
|
|
249
|
-
API
|
250
|
-
|
251
|
-
Ask questions on the forums: http://ecommerce.shopify.com/c/shopify-apis-and-technology
|
272
|
+
* [API Reference](https://help.shopify.com/api/reference)
|
273
|
+
* [Ask questions on the forums](http://ecommerce.shopify.com/c/shopify-apis-and-technology)
|
252
274
|
|
253
275
|
## Copyright
|
254
276
|
|
@@ -1,6 +1,17 @@
|
|
1
1
|
module ActiveResource
|
2
2
|
class DetailedLogSubscriber < ActiveSupport::LogSubscriber
|
3
3
|
def request(event)
|
4
|
+
log_request_response_details(event)
|
5
|
+
warn_on_deprecated_header(event)
|
6
|
+
end
|
7
|
+
|
8
|
+
def logger
|
9
|
+
ActiveResource::Base.logger
|
10
|
+
end
|
11
|
+
|
12
|
+
private
|
13
|
+
|
14
|
+
def log_request_response_details(event)
|
4
15
|
data = event.payload[:data]
|
5
16
|
headers = data.extract_options!
|
6
17
|
request_body = data.first
|
@@ -10,8 +21,20 @@ module ActiveResource
|
|
10
21
|
info "Response:\n#{event.payload[:response].body}"
|
11
22
|
end
|
12
23
|
|
13
|
-
def
|
14
|
-
|
24
|
+
def warn_on_deprecated_header(event)
|
25
|
+
payload = event.payload
|
26
|
+
|
27
|
+
payload[:response].each do |header_name, header_value|
|
28
|
+
case header_name.downcase
|
29
|
+
when 'x-shopify-api-deprecated-reason'
|
30
|
+
warning_message = <<~MSG
|
31
|
+
[DEPRECATED] ShopifyAPI made a call to #{payload[:method].upcase} #{payload[:path]}, and this call made
|
32
|
+
use of a deprecated endpoint, behaviour, or parameter. See #{header_value} for more details.
|
33
|
+
MSG
|
34
|
+
|
35
|
+
warn warning_message
|
36
|
+
end
|
37
|
+
end
|
15
38
|
end
|
16
39
|
end
|
17
40
|
end
|
@@ -13,15 +13,17 @@ module ShopifyAPI
|
|
13
13
|
module RequestNotification
|
14
14
|
def request(method, path, *arguments)
|
15
15
|
super.tap do |response|
|
16
|
-
notify_about_request(response, arguments)
|
16
|
+
notify_about_request(method, path, response, arguments)
|
17
17
|
end
|
18
18
|
rescue => e
|
19
|
-
notify_about_request(e.response, arguments) if e.respond_to?(:response)
|
19
|
+
notify_about_request(method, path, e.response, arguments) if e.respond_to?(:response)
|
20
20
|
raise
|
21
21
|
end
|
22
22
|
|
23
|
-
def notify_about_request(response, arguments)
|
23
|
+
def notify_about_request(method, path, response, arguments)
|
24
24
|
ActiveSupport::Notifications.instrument("request.active_resource_detailed") do |payload|
|
25
|
+
payload[:method] = method
|
26
|
+
payload[:path] = path
|
25
27
|
payload[:response] = response
|
26
28
|
payload[:data] = arguments
|
27
29
|
end
|
data/lib/shopify_api/limits.rb
CHANGED
@@ -39,8 +39,7 @@ module ShopifyAPI
|
|
39
39
|
# @return {Integer}
|
40
40
|
#
|
41
41
|
def credit_limit(scope=:shop)
|
42
|
-
|
43
|
-
@api_credit_limit[scope] ||= api_credit_limit_param(scope).pop.to_i - 1
|
42
|
+
api_credit_limit_param(scope).pop.to_i - 1
|
44
43
|
end
|
45
44
|
alias_method :call_limit, :credit_limit
|
46
45
|
|
@@ -42,7 +42,7 @@ module ShopifyAPI
|
|
42
42
|
prefix_options, query_options = split_options(prefix_options) if query_options.nil?
|
43
43
|
"#{prefix(prefix_options)}#{collection_name}.#{format.extension}#{query_string(query_options)}"
|
44
44
|
end
|
45
|
-
|
45
|
+
|
46
46
|
# find an asset by key:
|
47
47
|
# ShopifyAPI::Asset.find('layout/theme.liquid', :params => {:theme_id => 99})
|
48
48
|
def self.find(*args)
|
@@ -57,7 +57,7 @@ module ShopifyAPI
|
|
57
57
|
resource
|
58
58
|
end
|
59
59
|
end
|
60
|
-
|
60
|
+
|
61
61
|
# For text assets, Shopify returns the data in the 'value' attribute.
|
62
62
|
# For binary assets, the data is base-64-encoded and returned in the
|
63
63
|
# 'attachment' attribute. This accessor returns the data in both cases.
|
@@ -65,28 +65,28 @@ module ShopifyAPI
|
|
65
65
|
attributes['value'] ||
|
66
66
|
(attributes['attachment'] ? Base64.decode64(attributes['attachment']) : nil)
|
67
67
|
end
|
68
|
-
|
68
|
+
|
69
69
|
def attach(data)
|
70
70
|
self.attachment = Base64.encode64(data)
|
71
71
|
end
|
72
|
-
|
72
|
+
|
73
73
|
def destroy
|
74
74
|
connection.delete(element_path(prefix_options.merge(:asset => {:key => key})), self.class.headers)
|
75
75
|
end
|
76
|
-
|
76
|
+
|
77
77
|
def new?
|
78
78
|
false
|
79
79
|
end
|
80
|
-
|
80
|
+
|
81
81
|
def method_missing(method_symbol, *arguments) #:nodoc:
|
82
82
|
if %w{value= attachment= src= source_key=}.include?(method_symbol)
|
83
83
|
wipe_value_attributes
|
84
84
|
end
|
85
85
|
super
|
86
86
|
end
|
87
|
-
|
87
|
+
|
88
88
|
private
|
89
|
-
|
89
|
+
|
90
90
|
def wipe_value_attributes
|
91
91
|
%w{value attachment src source_key}.each do |attr|
|
92
92
|
attributes.delete(attr)
|