- return binary_package_publishing_history_new(binary_package_name,
- binary_package_version,
- distro_arch_series_link,
- self_link,
- architecture_specific);
+ bpph = bpph_new(binary_package_name,
+ binary_package_version,
+ distro_arch_series_link,
+ self_link,
+ architecture_specific);
+
+ date_created = json_object_get_string
+ (json_object_object_get(o, "date_created"));
+ if (date_created)
+ strptime(date_created, "%FT%T", &bpph->date_created);
+
+ status = json_object_get_string(json_object_object_get(o, "status"));
+ if (status)
+ bpph->status = strdup(status);
+
+ return bpph;
+}
+
+static json_object *bpph_to_json(struct bpph *bpph)
+{
+ json_object *json;
+ char *date;
+
+ json = json_object_new_object();
+
+ json_object_object_add
+ (json,
+ "binary_package_name",
+ json_object_new_string(bpph->binary_package_name));
+
+ json_object_object_add
+ (json,
+ "binary_package_version",
+ json_object_new_string(bpph->binary_package_version));
+
+ json_object_object_add
+ (json,
+ "distro_arch_series_link",
+ json_object_new_string(bpph->distro_arch_series_link));
+
+ json_object_object_add
+ (json,
+ "self_link",
+ json_object_new_string(bpph->self_link));
+
+ json_object_object_add
+ (json,
+ "architecture_specific",
+ json_object_new_boolean(bpph->architecture_specific));
+
+ json_object_object_add
+ (json, "status", json_object_new_string(bpph->status));
+
+ date = malloc(strlen("YY-MM-DDThh:mm:ss+xxx") + 1);
+ strftime(date,
+ strlen("YY-MM-DDThh:mm:ss+xxx") + 1,
+ "%FT%T",
+ &bpph->date_created);
+
+ json_object_object_add
+ (json, "date_created", json_object_new_string(date));
+ free(date);
+
+ return json;