chargify_api_ares 1.1.0.pre → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.env +4 -0
- data/.gitignore +1 -0
- data/.rspec +1 -0
- data/.travis.yml +9 -0
- data/Gemfile +1 -1
- data/Gemfile.lock +7 -1
- data/HISTORY.md +9 -0
- data/README.md +1 -1
- data/chargify_api_ares.gemspec +4 -2
- data/examples/metadata.rb +58 -0
- data/examples/metafields.rb +32 -0
- data/lib/chargify_api_ares.rb +4 -2
- data/lib/chargify_api_ares/behaviors/inspectable.rb +33 -0
- data/lib/chargify_api_ares/behaviors/metadata.rb +61 -0
- data/lib/chargify_api_ares/behaviors/metafield.rb +30 -0
- data/lib/chargify_api_ares/resources/customer_metafield.rb +14 -1
- data/lib/chargify_api_ares/resources/invoice.rb +4 -4
- data/lib/chargify_api_ares/resources/subscription.rb +26 -3
- data/lib/chargify_api_ares/resources/subscription_metadata.rb +17 -0
- data/lib/chargify_api_ares/resources/subscription_metafield.rb +14 -1
- data/spec/cassettes/subscription/find.yml +266 -0
- data/spec/cassettes/subscription_metadata/create.yml +78 -0
- data/spec/cassettes/subscription_metadata/list-after-create.yml +77 -0
- data/spec/cassettes/subscription_metadata/list.yml +71 -0
- data/spec/factories.rb +1 -0
- data/spec/resources/customer_metafield_spec.rb +64 -0
- data/spec/resources/customer_spec.rb +4 -4
- data/spec/resources/subscription_metadata_spec.rb +54 -0
- data/spec/resources/subscription_metafield_spec.rb +63 -0
- data/spec/resources/subscription_spec.rb +27 -0
- data/spec/spec_helper.rb +14 -2
- metadata +78 -31
- data/lib/chargify_api_ares/metafield_xml_formatter.rb +0 -10
- data/lib/chargify_api_ares/resources/metafield.rb +0 -67
- data/spec/spec.opts +0 -2
@@ -1,67 +0,0 @@
|
|
1
|
-
module Chargify
|
2
|
-
class Metafield < Base
|
3
|
-
def on_csv_export?
|
4
|
-
scope.csv == "1" || scope.csv == true
|
5
|
-
end
|
6
|
-
|
7
|
-
def on_csv_export=(value)
|
8
|
-
value = (value == true || value == '1') ? '1' : '0'
|
9
|
-
scope.csv = value
|
10
|
-
end
|
11
|
-
|
12
|
-
def on_hosted_pages?
|
13
|
-
scope.hosted.any?
|
14
|
-
end
|
15
|
-
|
16
|
-
def on_hosted_pages=(*products)
|
17
|
-
scope.hosted = Array(products).flatten.map(&:to_s)
|
18
|
-
end
|
19
|
-
|
20
|
-
def on_hosted_pages
|
21
|
-
scope.hosted
|
22
|
-
end
|
23
|
-
|
24
|
-
# Private Interface
|
25
|
-
|
26
|
-
def self.resource; "metafield"; end
|
27
|
-
def self.element_name; "metafields"; end
|
28
|
-
|
29
|
-
def self.instantiate_record(record, prefix_options = {})
|
30
|
-
record = record.is_a?(Array) ? record.first : record
|
31
|
-
new(record, true).tap do |resource|
|
32
|
-
resource.prefix_options = prefix_options
|
33
|
-
resource.current_name = resource.name
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
def self.instantiate_collection(collection, prefix_options = {})
|
38
|
-
collection['metafields'].collect! { |record| instantiate_record(record, prefix_options) }
|
39
|
-
end
|
40
|
-
|
41
|
-
def load_attributes_from_response(response)
|
42
|
-
if (response_code_allows_body?(response.code) &&
|
43
|
-
(response['Content-Length'].nil? || response['Content-Length'] != "0") &&
|
44
|
-
!response.body.nil? && response.body.strip.size > 0)
|
45
|
-
attributes = self.class.format.decode(response.body)
|
46
|
-
attributes = attributes.is_a?(Array) ? attributes.first : attributes
|
47
|
-
|
48
|
-
resource = load(attributes, true)
|
49
|
-
resource.current_name = resource.name
|
50
|
-
@persisted = true
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
def reload
|
55
|
-
raise NotImplementedError, 'Metafields do not support loading of a single record'
|
56
|
-
end
|
57
|
-
|
58
|
-
def destroy
|
59
|
-
connection.delete("#{element_path}?current_name=#{URI.encode(current_name)}")
|
60
|
-
end
|
61
|
-
|
62
|
-
def element_path(id = nil, prefix_options = {}, query_options = nil)
|
63
|
-
"#{self.class.prefix}#{self.class.element_name}.xml"
|
64
|
-
end
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
data/spec/spec.opts
DELETED